Bullet Building Static Libraries

Post Reply
Random#9001
Posts: 10
Joined: Mon Mar 16, 2015 12:59 pm

Bullet Building Static Libraries

Post by Random#9001 »

I am attempting to make a distributable .exe file for my msvc project. I ran into the problem that I was trying too use two different runtimes with my project using static /MT and the bullet files using dynamic /MD or /MDd. I attempted to rebuild bullet with cmake and I switched off USE_MSVC_RUNTIME_LIBRARY_DLL which seemed to have something to do with the libraries. I also specifically made the runtime library /MT for the projects when I used ALL_BUILD. This still resulted in the built libraries having /MD or /MDd as their runtime library and I get this output:

A bunch of things like this resulting from two runtime libs:

Code: Select all

>MSVCRTD.lib(MSVCR120D.dll) : error LNK2005: _atoi already defined in LIBCMT.lib(atox.obj)
And a bunch of things like this resulting from two runtime libs:

Code: Select all

>BulletDynamics_Debug.lib(btGeneric6DofSpringConstraint.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease'

Code: Select all

1>BulletDynamics_Debug.lib(btGeneric6DofSpringConstraint.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0'
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Bullet Building Static Libraries

Post by Basroil »

The first one seems to be a config issue in your own code, but the second is just a simple project configuration issue. You need to make sure that all projects linked in the code have the same runtime library settings, MT, MTd, MD, or MDd. In your case, you'll want MT for all to start with, and then read up on how to use of DLL exporting/importing (MSDN has a decent introduction) .
Random#9001
Posts: 10
Joined: Mon Mar 16, 2015 12:59 pm

Re: Bullet Building Static Libraries

Post by Random#9001 »

No you see that's not the problem, the problem is I cant get my bullet libraries to compile in cmake with /MT it will only do /MDd
Random#9001
Posts: 10
Joined: Mon Mar 16, 2015 12:59 pm

Re: Bullet Building Static Libraries

Post by Random#9001 »

It seems that what I had to do was import the actual projects and do as you said, making them all use /MTd. (They wont use /MT but if that ends up being a problem i'll come back and edit this) I'm not sure if it works yet, but before I was somehow referencing libraries I had compiled with Cmake and I thought I was changing the libraries but it was entirely possible I was somehow using the libraries of projects I had referenced earlier on and then removed from my project. I dont really know but Im going to go test now so thanks for the help so far.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Bullet Building Static Libraries

Post by Basroil »

Random#9001 wrote:It seems that what I had to do was import the actual projects and do as you said, making them all use /MTd. (They wont use /MT but if that ends up being a problem i'll come back and edit this)
Try switching from debug to release if you want /MT rather than /MTd. The solution file that came with bullet works 100% out of the box with a debug and release mode already configured in VS2010 and up (tested on VS2010 express, VS2012 express and pro, VS2013 community and pro, and VS2015 beta.
Post Reply