Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning LNK4075 when a C++/CLI project references a static lib project with /ZI (Edit And Continue)

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.

like image 542
Yodan Tauber Avatar asked Feb 23 '14 08:02

Yodan Tauber


2 Answers

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.

like image 190
Hans Passant Avatar answered Nov 03 '22 12:11

Hans Passant


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...

like image 45
Jochen Kalmbach Avatar answered Nov 03 '22 13:11

Jochen Kalmbach