Library conflict
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.
That library you are using is the debug library. Make sure you are building against the debug runtime DLL
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
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
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Currently, "Runtime library" in the "Code generation" tab is set to "Multi-threaded Debug (/MTd)". What should it be set to?
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.
* 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.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
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.
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.
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?
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?
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.
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
* 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
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement