Question

I have the following projects in a Visual Studio 2012 solution:

  • Native (no /clr) static lib project, compiled with /ZI for Edit And Continue.
  • C++/CLI DLL project, which references the above static lib.

The C++/CLI project builds with the following warning:

warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification

If /OPT:NOLBR is added to the linker options of the C++/CLI project, the warning becomes:

warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification

Any attempt to change the incremental linkage setting of the C++/CLI project doesn't change the warning (C++/CLI projects never link incrementally anyway).

I understand that I won't be able to use Edit And Continue in the C++/CLI project, because this is not supported. Indeed, changing /ZI to /Zi (disabling Edit And Continue) in the static lib project eliminates the warning, but I can't do that - other non-CLR consumers of that lib need to use Edit And Continue.

How can I get rid of this warning without disabling Edit And Continue in the static lib (and hopefully without maintaining separate build configuration for native and CLR users of the static lib)? I mean, is there any way to ask the linker to ignore the /EDITANDCONTINUE directive that is embedded in the referenced static lib (much in the same way that /NODEFAULTLIB can ignore /DEFAULTLIB directives)?

I have created a minimal VS solution that reproduces the described issue.

Was it helpful?

Solution

due to '/OPT:LBR' specification

This is a nonsense error message, that linker option is only effective for ARM binaries. This is simply a bug, using /OPT:NOLBR takes the sting out of it and you get the real warning.

Which is accurate enough, although it doesn't win any prizes either, you asked for Edit+Continue support in your static lib project but that is not available for a mixed-mode .NET assembly. The undocumented /IGNORE linker option is available to suppress warning messages but this one is ranked as an "unignorable warning" by Chapell.

You'll have to live with this warning as long as you don't want to change your static lib project. It is completely benign. You won't get it when you recompile it with /Zi.

OTHER TIPS

There is no other way than to

  • disable "Edit And Continue" in the library
  • create a separate build configuration for "Edit And Continue (/ZI)" and "Program Database (/Zi)"

Of course: I am not aware that there is a predefined macro to determine between /ZI and /Zi... so you need to define your own preprocessor directive to distinguish between these configurations...

I had the same problem and found the only solution is to delete the .vcxproj and .sln files of the project and create the project again. But then in an old copy of the same project I found a better solution: I changed in the projectname.vcxproj file the line Profile true to Profile false and LNK4075 warnings disappeared. It had been the Visual Studio Profiler who had caused the troubles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top