Link errors with VS2008

deavik
Posts: 2
Joined: Mon Jun 08, 2009 7:18 pm

Link errors with VS2008

Post by deavik »

Hi, I recently started using VS2008 express and also Bullet, but I can't get the bullet libraries to link without errors.

I used the msvc\8\wksbullet.sln (and VS said it could convert it to work with VS 9 just fine). However, for both "Release" and "Debug" configurations I get:

Code: Select all

1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
...
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static void __cdecl std::locale::facet::operator delete(void *)" (??3facet@locale@std@@SAXPAX@Z) already defined in libcpmtd.lib(locale0.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast@std@@QAE@PBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
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>C:\Users\avik\Documents\Visual Studio 2008\Projects\boost_tests\Debug\boost_tests.exe : fatal error LNK1169: one or more multiply defined symbols found
The demos work fine. My project uses /MDd (debug) and /MD (release) and I usually use dlls for external libraries. If I choose ReleaseDLL and the configuration, a) it doesn't build any DLLs, only .lib files, b) the demos when run give an error like MSVCR90.dll not found.

I would be glad if someone could help me out, including if someone has got it to work with VS2008 express.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Link errors with VS2008

Post by Erwin Coumans »

I usually use dlls for external libraries.
Unfortunately, dynamic linking Bullet is not supported.

Have you tried statically linking?
Thanks,
Erwin
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Link errors with VS2008

Post by Nacho »

The LNK2005 errors are because you are using /MD and /MDd, as you say, but in Bullet lib you are using other runtime lib format (/MT or /MTd). You must use Bullet ReleaseDLL. It generates .lib, no .dll because the only diference is the "Runtime Library" option.

If you need MSVCR90.dll library, you can obtain from VC (http://msdn.microsoft.com/en-us/library/ms235299.aspx)

If the LNK4098 error persists, try to put in "Ignore Specific Library" option LIBCMTD.lib in Debug and LIBCMT.lib in Release.

I hope this help.

Nacho
deavik
Posts: 2
Joined: Mon Jun 08, 2009 7:18 pm

Re: Link errors with VS2008

Post by deavik »

Hi, thank you both for the responses, they were very helpful and I understand a little more what's going on but I still have problems. I got my application to link, both by setting my application to /MT and also using Bullet's DebugDLL configuration (in which case you link to bulletdir\out\debug_dll8\build\libbulletmath\libbulletmath.lib, bulletdir\out\debug_dll8\build\libbulletdynamics\libbulletdynamics.lib, etc. right?)

BUT, I get a access violation error and crash from the Hello world example in the wiki. :(

The crash is from the line

Code: Select all

collisionObject->getCollisionShape()->getAabb(trans,minAabb,maxAabb);
in btCollisionWorld.cpp, which is called from the line

Code: Select all

btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI);
in the Hello world program. http://www.continuousphysics.com/mediaw ... ello_World

I don't know if this crash is because of an error in the code or because of runtime mangling, would you happen to know?

Thanks a ton!
dopplex
Posts: 1
Joined: Tue Jun 16, 2009 4:40 pm

Re: Link errors with VS2008

Post by dopplex »

I just figured out the solution to the access violation issue (well, for me anyway), and figured I should share since I didn't actually see it mentioned when I was googling for it last night.

Try defining WIN32 in Project Properties->C/C++->Preprocessor->Preprocessor definitions. That solved it for me.