Sign in to follow this  

Library conflict

This topic is 3784 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to link my project to angelscriptd.lib, but when I do that, I get a bunch of linker errors: 1>Linking... 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __wassert already defined in LIBCMTD.lib(wassert.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fprintf already defined in LIBCMTD.lib(fprintf.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fopen already defined in LIBCMTD.lib(fopen.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __vsnprintf already defined in LIBCMTD.lib(vsnprint.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgheap.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgheap.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strtol already defined in LIBCMTD.lib(strtol.obj) 1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strtoul already defined in LIBCMTD.lib(strtol.obj) 1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) 1>MSVCRTD.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 LIBCMTD.lib(typinfo.obj) 1> Creating library Debug\wx_MUD_2.lib and object Debug\wx_MUD_2.exp 1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>Debug\wx_MUD_2.exe : fatal error LNK1169: one or more multiply defined symbols found 1>Build log was saved at "file://e:\My Documents\My C++\wx_MUD_2\wx_MUD_2\Debug\BuildLog.htm" I haven't run into this before with compiling / running the sample. Should I just do the "/NODEFAULTLIB" option or is there are larger issue here? I apologize, I love programming but am a bit of a noob when it comes to linking and libraries and such.

Share this post


Link to post
Share on other sites
To be more specific, you'll have to check your compiler settings for both the library project and your application project so that they are compatible.

It's settings under "Code generation" that specifies which version of the C runtime library is used. Go to "Project (menu)->Settings (menu)->C/C++ (tab)->Code generation (combo box)" and verify the "Use runtime library" setting.

Regards,
Andreas

Share this post


Link to post
Share on other sites
You can use which ever you like, you just need to make sure it is the same for both the angelscript library and your application.

* statically linked is slightly faster, but generates larger binaries.

* single threaded is slightly faster, but may not work in multi threaded applications.

* debug is for debugging (duh!), and shouldn't be used for the final release version.


Share this post


Link to post
Share on other sites
I am staticly linking AngelScript, but my project also uses wxWidgets. I'm not sure how wx is linked, as I didn't set it up myself and instead used wxPack so that I could easily begin a new wxWidgets template in VC++. My other AngelScript program that ran fine but ran in the console used a Multi-Threaded Debug DLL, so I tried setting that option for the wx project, but alas, there were even more errors this time around.

I am currently compiling in Debug mode. If wxWidgets is linked dynamically (not sure if it is), does that mean AS must also be linked dynamically?

Sorry for all this... I know a lot about actual programming, but nearly nothing about compilers/linking.

Share this post


Link to post
Share on other sites
I have no experience with wxWidgets, but you can definitely have a mix of static and dynamically linked objects.

I assume your project compiles when you've removed all AS references? If so, remove all references so your program compiles, then try this:

1. Load up the AS project and compile the debug build. This will generate the angelscriptd.lib file. Copy this file into a <code base>\lib directory.

2.Load up VS.

3. Under Project -> Properties -> Common Properties
add the <code base>\lib directory to "additional reference search paths"

4. Go to the Configuration Properties -> Linker page

5. Under "additional dependencies" add "angelscriptd.lib"

6. Copy the "angelscript.h" file to your code base.

7. Include "angelscript.h" in your .h file(s) as needed

8. Ensure that wxWidgets is using a debug build. if not, rebuild so it is (not sure how, like I said, 0 xp with this)


maybe this helps somewhat?

Share this post


Link to post
Share on other sites
I tried your method. I got it to work fine -- up until I put "scriptstring.cpp" and "scriptstring_utils.cpp" into the project. Then the linker threw all of the errors listed in my initial post.

Share this post


Link to post
Share on other sites
Based on your linker errors you have two different versions of the C run time library:

* Debug Single-Threaded DLL (MSVCR80D.dll)
* Debug Multithreaded non-DLL (LIBCMTD.lib)

Try changing your application project settings and AngelScript project settings to use Debug Multithreaded non-DLL as well.

If wxWidgets is dynamically linked, you shouldn't have any conflicts with it (unless the library is badly written). If it is statically linked, you'll have to make sure you're using the same C run time in all your libraries.

Have you made sure the AngelScript library uses the same C run time library as your application? If you're still getting linker errors after that it means you're having conflicts with wxWidgets.

You can also try a different approach, and that is to include all AngelScript source files in your own application project instead of linking with them as a static library. If you still get linker errors after that, then it's definitely not because of AngelScript.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
Have you made sure the AngelScript library uses the same C run time library as your application? If you're still getting linker errors after that it means you're having conflicts with wxWidgets.


How do I do this? I'm just adding "angelscriptd.lib" to my dependancy list, I'm not sure how to configure its runtime separately from that of the rest of my project.

Share this post


Link to post
Share on other sites
The same way you do it for your application. You'll have to open the project settings for the library and choose the runtime library it should use. Then recompile the library before linking it with your application.

Share this post


Link to post
Share on other sites
Okay, I went back and opened the "msvc8" solution in the angelscript folder. I checked the runtime library, it was set to "Multi-threaded Debug DLL". I made sure I was in debug mode. I compiled the library, then copied it into the VC\lib directory, overwriting the previous instance of "angelscriptd.lib". I then went into the project I'm having problems with that uses angelscript. I set it to "Multi-threaded Debug DLL", and the linker had this to say:

1>Linking...
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetDbgFlag already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(setlocal.obj) : error LNK2005: _setlocale already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(strtol.obj) : error LNK2005: _strtoul already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(mbstowcs.obj) : error LNK2005: _mbstowcs already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(wcstombs.obj) : error LNK2005: _wcstombs already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(swprintf.obj) : error LNK2005: __swprintf already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(iswctype.obj) : error LNK2005: _iswctype already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(ismbbyte.obj) : error LNK2005: __ismbblead already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMTD.lib(fputwc.obj) : error LNK2005: _fputwc already defined in MSVCRTD.lib(MSVCR80D.dll)
1> Creating library Debug\wx_MUD_2.lib and object Debug\wx_MUD_2.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>Debug\wx_MUD_2.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://e:\My Documents\My C++\wx_MUD_2\wx_MUD_2\Debug\BuildLog.htm"

Share this post


Link to post
Share on other sites
The situation changed. Now for the inverse. :)

Looks like you're linking with wxWidgets as a static library, or maybe you're linking with some other library as well.

Try changing the setting to Debug Single-threaded (non-DLL) for both AngelScript and your application.

Share this post


Link to post
Share on other sites
There is no "single-threaded" option. Do you mean "Multi-threaded Debug"?

My options are "Multi-threaded", "Multi-threaded Debug", "Multi-threaded DLL", and "Multi-threaded Debug DLL".

Share this post


Link to post
Share on other sites
There isn't? Have Microsoft removed that option for MSVC 8.0?

Well, then I suppose you should use "Multi-threaded Debug".

LIBCMTD.lib must be coming from wxWidgets since you set both AngelScript and your application to use "Multi-threaded Debug DLL". Changing to the non-DLL version should work.

Share this post


Link to post
Share on other sites

This topic is 3784 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this