I had the same problem, so I did some research.
According to https://msdn.microsoft.com/en-us/library/0zza0de8.aspx :
If you compile your program with /GL and /c, you should use the /LTCG
linker option to create the output file.
So the message can be a bit misleading - the problem is not the MSIL .netmodule
, but modules compiled with /GL
When using /GL
, you tell the compiler to delay the generation of some code namely around function bounderies, in order to optimise them. LTCG
instruct the linker to generate (and optimise) the missing code. Otherwise, the program will not run as expected.
Basically, the two switches should be used together (when used). They apply to different parts of the build: one for compilation and the other one for link.
For completeness:
/GL
is controlled from Configuration Properties > C/C++ > Optimization > Whole Program Optimization
/LTCG
is controlled from Configuration Properties > Linker > Optimization > Whole Program Optimization
On later versions,
/LTCG
is controlled from Configuration Properties > Linker > Optimization > Link Time Code Generation / Use Link Time Code Generation (/LTCG)