Linking Problem !! Something to do with Multi-threading
-
I was trying to includeThe nFS Library[^] in my project, but I couldn't do it like the demo application, where he didn't include neither the .h files nor the .lib file into the project.:wtf: When I tried to recompile my program with including all the .h and .cpp files of the libraries it worked. :) Since my project is already full with files, so I removed all these files, and included only the .lib file, and recompiled the program. and I got the following error :confused:
LIBCMT.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj) msvcrtd.lib(MSVCR70D.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj) LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug/Trial.exe : fatal error LNK1120: 1 unresolved externals
When I put /NODEFAULTLIB:LIBCMT, it works fine. But I will need multi-threading for an even more important Library. :doh: So, what are the consequences of adding that line to the commandline of Linker....... and what can I do to solve my problem without having to add it. Do I have to go back to adding all the .h and .cpp files of the library.... or:doh:. Please help. :(( :rose: -
I was trying to includeThe nFS Library[^] in my project, but I couldn't do it like the demo application, where he didn't include neither the .h files nor the .lib file into the project.:wtf: When I tried to recompile my program with including all the .h and .cpp files of the libraries it worked. :) Since my project is already full with files, so I removed all these files, and included only the .lib file, and recompiled the program. and I got the following error :confused:
LIBCMT.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR70D.dll) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj) LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj) msvcrtd.lib(MSVCR70D.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj) LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug/Trial.exe : fatal error LNK1120: 1 unresolved externals
When I put /NODEFAULTLIB:LIBCMT, it works fine. But I will need multi-threading for an even more important Library. :doh: So, what are the consequences of adding that line to the commandline of Linker....... and what can I do to solve my problem without having to add it. Do I have to go back to adding all the .h and .cpp files of the library.... or:doh:. Please help. :(( :rose:This happens when you try to link things together that have been compiled with different settings. Go through *every* single library that you are linking in and make sure you are using the correct one i.e. multi-threaded. You also need to check the DLL/not-DLL switches are all the same as well.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
-
This happens when you try to link things together that have been compiled with different settings. Go through *every* single library that you are linking in and make sure you are using the correct one i.e. multi-threaded. You also need to check the DLL/not-DLL switches are all the same as well.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
Thanks It worked fine. :rose: