尝试使用子弹物理库时VS中出现lnk2001错误 我是C++的新成员,VisualStudio(2019)和Mulk(2.89)。 在过去的几天里,我一直在努力从Bullet构建Hello_World.cpp,但我遇到了以下5个链接错误: 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btCollisionShape::getBoundingSphere(class btVector3 &,float &)const " (?getBoundingSphere@btCollisionShape@@UBEXAAVbtVector3@@AAM@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall btCollisionShape::getAngularMotionDisc(void)const " (?getAngularMotionDisc@btCollisionShape@@UBEMXZ) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall btCollisionShape::getContactBreakingThreshold(float)const " (?getContactBreakingThreshold@btCollisionShape@@UBEMM@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btConvexShape::project(class btTransform const &,class btVector3 const &,float &,float &,class btVector3 &,class btVector3 &)const " (?project@btConvexShape@@UBEXABVbtTransform@@ABVbtVector3@@AAM2AAV3@3@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btSphereShape::calculateLocalInertia(float,class btVector3 &)const " (?calculateLocalInertia@btSphereShape@@UBEXMAAVbtVector3@@@Z)

尝试使用子弹物理库时VS中出现lnk2001错误 我是C++的新成员,VisualStudio(2019)和Mulk(2.89)。 在过去的几天里,我一直在努力从Bullet构建Hello_World.cpp,但我遇到了以下5个链接错误: 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btCollisionShape::getBoundingSphere(class btVector3 &,float &)const " (?getBoundingSphere@btCollisionShape@@UBEXAAVbtVector3@@AAM@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall btCollisionShape::getAngularMotionDisc(void)const " (?getAngularMotionDisc@btCollisionShape@@UBEMXZ) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall btCollisionShape::getContactBreakingThreshold(float)const " (?getContactBreakingThreshold@btCollisionShape@@UBEMM@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btConvexShape::project(class btTransform const &,class btVector3 const &,float &,float &,class btVector3 &,class btVector3 &)const " (?project@btConvexShape@@UBEXABVbtTransform@@ABVbtVector3@@AAM2AAV3@3@Z) 1>Hello_World.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btSphereShape::calculateLocalInertia(float,class btVector3 &)const " (?calculateLocalInertia@btSphereShape@@UBEXMAAVbtVector3@@@Z),c++,static-linking,bullet,lnk2001,C++,Static Linking,Bullet,Lnk2001,还有其他人有这个或类似的问题,但没有得到答案,或者对我不起作用 设置: 我使用premake设置VS解决方案,Bullet是在静态库中组织的(作为源代码被编译为lib文件的项目),现在我正尝试将它们与应用程序项目链接 所有项目都使用静态链接(用于调试) 我已将所有bullet项目引用到我的项目中 我甚至从bullet静态链接到lib文件(链接器显然可以看到这些文件,我甚至尝试给出绝对路径) 据我所知,函数存在并且在.cpp和.h文件中具有相同的签名 如果你需要更多的细节,请告诉我 (我可能得

还有其他人有这个或类似的问题,但没有得到答案,或者对我不起作用

设置:

  • 我使用premake设置VS解决方案,Bullet是在静态库中组织的(作为源代码被编译为lib文件的项目),现在我正尝试将它们与应用程序项目链接
  • 所有项目都使用静态链接(用于调试)
  • 我已将所有bullet项目引用到我的项目中
  • 我甚至从bullet静态链接到lib文件(链接器显然可以看到这些文件,我甚至尝试给出绝对路径)
  • 据我所知,函数存在并且在.cpp和.h文件中具有相同的签名
如果你需要更多的细节,请告诉我

(我可能得到的一条线索是关于不同的bt_双_精度?但可能不是这样,我唯一能找到的是使用不同精度的浮点模型。但同样的方法也没用)

提前谢谢

编辑: 我认为这个答案不适用于我

编辑: 也许值得一提:项目的文件结构非常奇怪(由premake指定):

  • 解决方案和项目文件位于:bullet3-2.89\build3\vs2010
  • 高级头文件(Hello_World使用的头文件包括其他头文件):bullet3-2.89\src
  • 源文件和头文件是bullet3-2.89\src的子目录
  • 库:bullet3-2.89\bin 但是所有的头文件都在include中使用了正确的相对路径,我已经将项目的include和library目录设置到了这些位置

    • 我找到了一个解决办法。只是想劫持Bullet中的一个示例项目,并使用它。他们似乎比我更擅长VS设置:D
      无论如何,谢谢你的建议。

      也有同样的问题,只有一些函数没有链接

      这很可能是由于构建的项目符号库具有
      BT\u USE\u DOUBLE\u精度
      ,这意味着所有
      btScaler
      都将是DOUBLE类型

      但是库中没有包含
      BT\u USE\u DOUBLE\u PRECISION
      ,这意味着程序将尝试与函数的浮点版本链接。

      但它们不存在,因为内置版本使用了双精度。

      这是否回答了您的问题?这五个函数是唯一找不到的函数,还是还有更多的函数?这五个函数都声明为
      const
      。但是,也许这个库是用它们构建的,而不是
      const
      。尝试从头文件中删除
      const
      ,看看会发生什么。如果无法解决问题,请撤消更改。@这些是Hello_World.cpp的唯一更改,但如果我从调用更多函数,可能会有更多更改Bullet@Dialecticus我从源文件开始编译库,源文件和头文件中的const匹配