0

I'm new to C++, Visual Studio (2019) and Bullet (2.89). I've been tying to build the Hello_World.cpp from Bullet for the past few days but I'm stuck on these 5 linking errors:

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)

There are other people who had this or a similar problem but got no answer or it didn't work for me.

setup:

  • I used premake to set up the VS solution, Bullet is organized in static Libraries (as projects with source code that gets compiled to lib files) and I am now trying to link them with an application-project.
  • all projects are using static linking (for debug).
  • I've referenced all bullet projects to my project.
  • I've even staticly linked to the lib files from bullet (and the linker can apparently see these files, I even tried giving the absolute path)
  • As far as I can tell the functions exist and have the same signature in the .cpp and .h files

If you need more details let me know.

(One lead I possibly got is something about different bt_double_precision? But that might not be it and the only think I could find was floating point model using different precision. But making that the same didn't do anything)

Thanks in advance!

EDIT: I don't think this answer applies to me

What is an undefined reference/unresolved external symbol error and how do I fix it?

EDIT: Maybe worth mentioning: The file structure of the project is really weird (dictated by premake):

  • solution and project files are in: bullet3-2.89\build3\vs2010
  • high level header files(these are the ones used by Hello_World that include other headers): bullet3-2.89\src
  • source and header files are subdirectories of bullet3-2.89\src
  • libraries: bullet3-2.89\bin but all headers use the correct relative paths in their include and I have set the project's include and library directories to those locations
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Richard Critten Apr 27 '20 at 09:01
  • Are these five functions the only ones that cannot be found, or are there more? – Dialecticus Apr 27 '20 at 09:04
  • All five of these are declared as `const`. But maybe the library was built with them not being `const`. Try to remove `const` from header files and see what happens. Undo the changes, if they don't solve the problem. – Dialecticus Apr 27 '20 at 09:07
  • @Dialecticus these are the only ones for Hello_World.cpp but maybe there would be more if I called more functions from Bullet – Lieven Petersen Apr 27 '20 at 09:20
  • @Dialecticus I compiled the library from the source files to begin with and the const matches in source and header files – Lieven Petersen Apr 27 '20 at 09:23
  • @RichardCritten going through the list there is nothing that occurs to me as plausible – Lieven Petersen Apr 27 '20 at 09:39
  • I think you would be better served if you ask this question in [Bullet forum](https://pybullet.org/Bullet/phpBB3/viewforum.php?f=9). – Dialecticus Apr 27 '20 at 10:31
  • @Dialecticus good idea, did that now https://pybullet.org/Bullet/phpBB3/viewtopic.php?f=9&t=12944 – Lieven Petersen Apr 27 '20 at 10:55

2 Answers2

1

Had the same issue where just a few of the functions didn't link.

This is most likely due to the Bullet library being built with BT_USE_DOUBLE_PRECISION, meaning all btScaler will be of type double.

But the library is included without BT_USE_DOUBLE_PRECISION, meaning the program will try to link with the float versions of the functions.
But they don't exists since the built version uses doubles.

Theodor
  • 11
  • 2
0

I found a workaround. Just gonna hijack one of the example projects from Bullet and use that instead. They seem to be better at VS settings than me :D Anyway, thanks for your suggestions.