/INCLUDE (Force Symbol References)
Visual Studio 2005
/INCLUDE:symbol
The /INCLUDE option tells the linker to add a specified symbol to the symbol table.
To specify multiple symbols, type a comma (,), a semicolon (;), or a space between the symbol names. On the command line, specify /INCLUDE:symbol once for each symbol.
The linker resolves symbol by adding the object that contains the symbol definition to the program. This feature is useful for including a library object that otherwise would not be linked to the program.
Specifying a symbol with this option overrides the removal of that symbol by /OPT:REF.
To set this linker option in the Visual Studio development environment
-
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
-
Click the Linker folder.
-
Click the Input property page.
-
Modify the Force Symbol References property.
To set this linker option programmatically
Difference with x86 and x64 compiler and/or linker using the linker's /INCLUDE:symbol option.
Seems to be a strange difference with x86 and x64 compiler and/or linker:
Given:
x.cpp
EXTERN_C int forcethis = 1;
x.h
#pragma comment(linker, "/INCLUDE:_forcethis") (or on the linker command line: /INCLUDE:_forcethis)
Compiled and link for Win32/x86: Okay
Compiled and link for Win64/x64: Unresolved external _forcethis.
If you remove the underscore like, /INCLUDE:forcethis then Win64/x64 links okay. However, Win32/x86 will fail with unresolved external _forcethis.
What gives with the compiler comment record or linker differences?
Given:
x.cpp
EXTERN_C int forcethis = 1;
x.h
#pragma comment(linker, "/INCLUDE:_forcethis") (or on the linker command line: /INCLUDE:_forcethis)
Compiled and link for Win32/x86: Okay
Compiled and link for Win64/x64: Unresolved external _forcethis.
If you remove the underscore like, /INCLUDE:forcethis then Win64/x64 links okay. However, Win32/x86 will fail with unresolved external _forcethis.
What gives with the compiler comment record or linker differences?
- 3/9/2011
- MerkX