Linker Tools Error LNK1237

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Linker Tools Error LNK1237.

during code generation, compiler introduced reference to symbol 'symbol' defined in module 'module' compiled with /GL

During code generation, the compiler should not introduce symbols that are later resolved to definitions compiled /GL. symbol is a symbol that was introduced and later resolved to a definition compiled with /GL.

For more information, see /GL (Whole Program Optimization).

To resolve LNK1237, do not compile the symbol with /GL or use /INCLUDE (Force Symbol References) to force a reference to the symbol.

The following sample generates LNK1237. To resolve this error, do not initialize the array in LNK1237_a.cpp and add /include:__chkstk to the link command.

// LNK1237_a.cpp  
int main() {  
   char c[5000] = {0};  
}  

// LNK1237_b.cpp  
// compile with: /GS- /GL /c LNK1237_a.cpp  
// processor: x86  
// post-build command: (lib LNK1237_b.obj /LTCG & link LNK1237_a.obj LNK1237_b.lib /nodefaultlib /entry:main /LTCG)  
extern "C" void _chkstk(size_t s) {}  

Show: