How to ensure that the /EDITANDCONTINUE directive

2020-04-11 04:58发布

I get this message when I try to edit and continue in VSC15:

'file.cpp' in 'LIB.DLL' was not linked with Edit and Continue enabled. 
Ensure that /INCREMENTAL linking is enabled, and the /EDITANDCONTINUE directive is not ignored.

I've already ensured that /INCREMENTAL is enabled but can't figure out the second part.

Compiler command line:

/Yu"stdfx.h" /GS /analyze- /W3 /Gy /Zc:wchar_t /ZI /Gm- /Od /Fd".\Debug\vc140.pdb" /Zc:inline /fp:fast /D "x86" /D "WIN32" /D "_WINDOWS" /D "DEBUG" /D "_UNICODE" /D "UNICODE" /D "_WINDLL" /errorReport:none /WX- /Zc:forScope /RTC1 /GR /Gd /Oy- /MTd /Fa".\Debug\" /EHsc /Fo".\Debug\" /Fp".\Debug\LIB.pch"

Linker command line:

/OUT:".\Debug\LIB.dll" /MANIFEST:NO /NXCOMPAT /PDB:".\Debug\LIB.pdb" /DYNAMICBASE /DEF:"EXPORT.DEF" /IMPLIB:".\Debug\LIB.lib" /DLL /MACHINE:X86 /NODEFAULTLIB:"libc.lib" /OPT:REF /SAFESEH /INCREMENTAL /PGD:".\Debug\LIB.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:".\Debug\LIB.dll.intermediate.manifest" /MAP /OPT:ICF

4条回答
劫难
2楼-- · 2020-04-11 05:34

I had the same problem, did all steps described above but no luck.

I use VS2017.

Helped next: you have to specify /ZI for each specific *.cpp file in your project:

  • right click on the *.cpp file in the Solution Explorer
  • Properties > C/C++ > General > Debug Information Format = Program Database for Edit And Continue (/ZI)
查看更多
兄弟一词,经得起流年.
3楼-- · 2020-04-11 05:41

The complete official answer for vs2015 case is here https://blogs.msdn.microsoft.com/vcblog/2016/07/01/c-edit-and-continue-in-visual-studio-2015-update-3/ Also it may be helpful to read this one https://blogs.msdn.microsoft.com/vcblog/2013/10/29/the-visual-c-linker-best-practices-developer-iteration/

As for my case I haven't seen any uncompatible flags in linking command line, and it turned out that

/LTCG

is turned on by default, so I had to turn it of manually with additional linker option in every project of my solution

/LTCG:OFF

查看更多
【Aperson】
4楼-- · 2020-04-11 05:46

Looking at the command lines:

Compiler command line: Edit and Continue isn't really compatible with /Gm-, it requires "Enable Minimal Rebuild" (/Gm).

Linker command line: /OPT:REF, /SAFESEH, /OPT:ICF are all incompatible with Edit and Continue and should cause LNK4075.

If you try a clean build of LIB.dll, you should see warnings such as:

1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification
1>ConsoleApplication1.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
查看更多
劫难
5楼-- · 2020-04-11 05:56

Try turning off SAFESEH on the advanced page of the linker settings.

/SAFESEH:NO

查看更多
登录 后发表回答