14

我在 Windows 7 和 Visual Studio 2012 上使用 Bullet Physics。我已经编译了库,并且演示工作正常,但是当我尝试创建自己的解决方案时,出现链接错误。我已将代码量降至最低

#include "btBulletDynamicsCommon.h"
int main(int argc, char*argv[])
{
    btBoxShape* box = new btBoxShape(btVector3(1, 1, 1));
    return 0;
}

当我链接时,使用 Visual Studio 会给我以下错误:

1>------ Build started: Project: HelloBulletApp, Configuration: Release Win32 ------  
1>  main.cpp  
1>  main.obj : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG;   add /LTCG to the link command line to improve linker performance
1>BulletCollision.lib(btCollisionShape.obj) : error LNK2038: mismatch detected for   'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>BulletCollision.lib(btConvexShape.obj) : error LNK2038: mismatch detected for   'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>BulletCollision.lib(btPolyhedralConvexShape.obj) : error LNK2038: mismatch detected for   'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>BulletCollision.lib(btConvexPolyhedron.obj) : error LNK2038: mismatch detected for   'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>LinearMath.lib(btConvexHullComputer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>LinearMath.lib(btGeometryUtil.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>c:\path\to\HelloBulletApp\HelloBulletApp\Release\HelloBulletApp.exe : fatal error LNK1319: 6 mismatches detected

当我在调试或发布模式下构建时,会出现相同的错误。我尝试过:
- 重建项目符号 2.81,
- 重新下载 2.81,
- 创建一个空白项目并添加库,
- 创建一个空白项目并按照 http://bulletphysics.org/mediawiki-1.5.8/中的建议添加项目index.php/Creating_a_project_from_scratch,但无济于事。

有什么我可以做的吗?

4

1 回答 1

20

看起来 BulletCollision.lib 被编译为与 C 运行时库 (/MD) 的 DLL 版本链接,但您正在编译为与静态链接的运行时库 (/MT) 链接。更改编译器选项以链接 DLL 运行时库。

于 2012-11-18T21:41:23.407 回答