LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
-
Hi,
Although I've programmed quite a bit with Pascal (Embarcadero/MikroE) I'm new to Visual C++ and QT so my problem is probably quite simple to correct but apparently nearly impossible for this newbie to figure out on his own based on the past 24 hours of lost time getting nowhere.
I have an existing windows application developed in QT with Visual c++ 2010 compiler/linker. I need to make some minor changes. I've got QT Creator up and running and working with Visual c++ 2010. So far so good.
When I build the program I get several link error msgs which are basically summarized in the title to this post.
I've spent hours and hours scouring the web for info on what's going on here and while I've certainly learned a lot it's not enough to correct this problem and move on.
At this point I'm less interested in a broad tutorial on what this error msg means (I kind of get it based on searches). What I need is detailed hand holding on what to do to fix it. Dare I say it, I'm even willing to PAY SOMEONE to help me sort this out so I can move forward.
Sleepless in South Florida (a.k.a. Morten)
-
-
You should ask the author of the existing application how he/she managed to get it to link. If you made changes before getting it to build, back out those changes and get it to build first, without changing anything.
-
Select the project that is failing. Right-click, choose "Properties". Under "Configuration Properties", expand the "Linker" node. Under "Linker" select "Input". On the right hand side of the tab you will see an entry labelled "Ignore specific default libraries". Add MSVCRT to that entry.
-
-
[quote author="ScottR" date="1387308939"]1) You should ask the author of the existing application how he/she managed to get it to link. If you made changes before getting it to build, back out those changes and get it to build first, without changing anything.
- Select the project that is failing. Right-click, choose "Properties". Under "Configuration Properties", expand the "Linker" node. Under "Linker" select "Input". On the right hand side of the tab you will see an entry labelled "Ignore specific default libraries". Add MSVCRT to that entry.[/quote]
The project/source code is from a Microchip website so getting to the author isn't practical.
I've made no changes to the code. I'm just trying to compile/link it as is which is when this fun started.
To be clear, this is a QT project (*.pro), not a Visual c++ project. QT Creator uses Visual c++ 2010 as its compiler. So unless I'm more confused than I already think I am, going to Visual c++ to tweak properties of a project that's not under Visual c++ isn't going to work out so well. Don't I have to find a way to modify the *.pro file so qmake will have the correct configuration info to pass to the v++ compiler?
-
Hi and welcome to devnet,
Add this to your pro file and you should be good to go
@QMAKE_LFLAGS +=
"/nodefaultlib: name_of_the_lib_you_want_to_ignore.lib"@ -
I've tried numerous variations on "/nodefaultlib: ______" and also setting the /MT or /MD flags to no avail. Nothing changes the results.
Here is what I get every time I build.
link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST /MANIFESTFILE:windows\HIDBootloader.exe.embed.manifest /OUT:windows\HIDBootloader.exe @C:\Users\Morten\AppData\Local\Temp\HIDBootloader.exe.1340.2964.jom
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
Creating library windows\HIDBootloader.lib and object windows\HIDBootloader.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
windows\HIDBootloader.exe : fatal error LNK1169: one or more multiply defined symbols found -
@TortugaRanger:
Hi. I know it's been a year since you last posted your problem.
I do not have a solution but I am having the same issues.
I was just wondering if you had found a solution to the "already defined" linker errors?
Thanks -
@TortugaRanger:
Hi. I know it's been a year since you last posted your problem.
I do not have a solution but I am having the same issues.
I was just wondering if you had found a solution to the "already defined" linker errors?
Thanks -
"MSVCRT" is the runtime library of Visual Studio. Basically there are two versions of this code, a static linked (libcmt) one and a dynamic linked one (msvcrt), because you can link your application static or dynamic. ("Example for VS2013":http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx ) This can be changed in the project properties.
You are getting those message, e.g. if you have a statically linked programm, that uses an external library, which uses dynamically linked runtime code or vice versa. Then you have the same code twice and the linker reports an error.
If it is possible, stay with one kind of code generation. Otherwise you have to try out, what will work for you. You can change your software between static and dynamic. You can ignore libraries and add different libraries. Even the order of the libraries does matter. -
"MSVCRT" is the runtime library of Visual Studio. Basically there are two versions of this code, a static linked (libcmt) one and a dynamic linked one (msvcrt), because you can link your application static or dynamic. ("Example for VS2013":http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx ) This can be changed in the project properties.
You are getting those message, e.g. if you have a statically linked programm, that uses an external library, which uses dynamically linked runtime code or vice versa. Then you have the same code twice and the linker reports an error.
If it is possible, stay with one kind of code generation. Otherwise you have to try out, what will work for you. You can change your software between static and dynamic. You can ignore libraries and add different libraries. Even the order of the libraries does matter.