0

I am building a Windows OpenGL application with bullet physics support. My development environment setup is :

  • OS : Windows 7 SP1 64 bit
  • IDE ; Visual Studio 2010 SP1
  • BulletPhysics - bullet-2.82-r2704

My application has two configurations i.e. Win32 and x64. Here's my step to build the Windows application :

  1. First I execute the vs2010.bat file in "bullet-2.82-r2704\build".
  2. I add project files from vs2010 folder created by step 1 into my visual studio solution.
  3. Add project dependencies for BulletDynamics, BulletCollision and LinearMath
  4. Add References for all the thee bullet libraries.

Now when I build my solution for both the configurations (i.e Batch Build for Win32 and x64), everything builds properly except for :

x64 Release - with errors like :

    BulletCollision_vs2010_x64_debug.lib(btDefaultCollisionConfiguration.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in stdafx.obj

Win32 Release - with errors like :

    Win32_Window.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btConvexInternalShape ...

Win32 Debug - with errors like :

    Win32_Window.obj : error LNK2019: unresolved external symbol "public: __thiscall btRigidBody

Final message - Build: 13 succeeded, 3 failed

I am following this help to build my Visual Studio project :

http://bulletphysics.org/mediawiki-1.5.8/index.php/Creating_a_project_from_scratch#Create_a_new_Visual_Studio_project

Note: If I use CMAKE to build VisualStudio solutions for BulletPhysics and then link those separately to my windows application for each CPU architecture then it builds properly (i.e. Build for Win32 and x64 separately).

Is there any way I can make that work with just one Visual Studio solution ?

Manmohan Bishnoi
  • 791
  • 13
  • 37

1 Answers1

3

In x64 Release you are trying to link a static library compiled in debug mode (BulletCollision_vs2010_x64_debug.lib) with object files from your app compiled in release mode (stdafx.obj specifically). Compiler options (_ITERATOR_DEBUG_LEVEL) of your object files and compiler options of a lib don't match (values 0 for release and 2 for debug respectively). That's why linking fails. And in Win32 Debug and Win32 Release cases it looks like you don't link libs at all.

I think that project references went wrong way.

  1. In my opinion while "Project references" is good for C# style of modules, in native development it is more like unnecessary complication of things. Just add plain old libs to linker input explicitly, like this:

    ..\..\lib\BulletDynamics_vs2010_x64_debug.lib
    ..\..\lib\BulletCollision_vs2010_x64_debug.lib
    ..\..\lib\LinearMath_vs2010_x64_debug.lib
    

    Change "debug" and "x64" parts accordingly for each configuration. I think it is more reliable.

  2. Add BulletDynamics, BulletCollision and LinearMath to "Project dependencies" for your app project. That will guarantee that bullet will be built before your app. Check "Build order" tab to make sure that builds go in right order.
  3. Double check that compiler options are the same for each module.
  4. In <Build->Configuration manager> for all "Solution configurations" and all "Solution platforms" (dropdowns above) check that project configurations and platforms are right. (i.e. you don't have projects that use debug when you switch solution to release and vice versa)
  5. Still fails? Take a look at sample Bullet applications, like "App_HelloWorld". Compare it's options to your app's options, and you will surely find a source of error.
  6. Probably, you could make it other way around: add your app project to Bullet's solution (remove unneeded stuff), to see if it works.
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61