How to use /NODEFAULTLIBS option in compilation?
First you need to work out which library is causing the conflict, if you can. Does the link warning tell you anything?
Then you need to open the property pages for this project, and go to Linker -> Command Line. In the 'Additional Options' area, type:
/NODEFAULTLIB:xxx.lib
where xxx.lib is the conflicting library. However, if you couldn't work out which library it is, try just:
/NODEFAULTLIB
Cute
Updated on July 29, 2022Comments
-
Cute almost 2 years
I have a solution explorer contains 2 projects. For one project I have enabled
/clr
with/mdd
. For parent project I have/mtd
and no clr support. When I compile this I get two linker errors including the below one:Link warning link 4098:Default lib can conflict with other lib use /NODEFAULTLIBS library
So my question is how to use
/NODEFAULTLIBS
in compilation.Thanks in advance.
-
ForceMagic over 11 yearsCould you discuss about the impact of using such options in you answer? I've tried to use "/NODEFAULTLIB" and there is now a lot of function that the linker doesn't find.
-
Peter over 4 yearsYou have to figure out the library that is affected, although is not easy but is recommended. Using "/NODEFAULTLIB" is ambiguous and covers all default libraries and if you're depending on someway, you are sure to get a lot of linker issues.
-
David A. Gray over 2 yearsThink of a bare /NODEFAULTLIB as the nuclear option. There are almost always dependencies on the default CRT library, and maybe many others (MFC, ATL, etc.), which must be called out by name in the list of libraries to search when you select /NODEFAULTLIB. It's an option that is there when you need it, which should be very rare. Though I've used it a few times, I have regretted doing so almost every time, and usually ended up backing off.