Bullet as an external library

bangsh0718
Posts: 3
Joined: Thu Feb 21, 2019 2:48 am

Bullet as an external library

Post by bangsh0718 »

I would like to use Bullet3 as an external library in my C++ project and I am trying to use cmake as a build tool. I found FindBullet.cmake has saved only Dyanmics, Collision, Linear Math, and Softbody libraries in ${BULLET_LIBRARIES}. But, when I copied and pasted TwoJointMain.cpp in my project and tried to compile it by target linking the libraries, it failed because of the need for other libraries such as BussIK, BulletFileLoader, and so on. So, I edited the FindBullet.cmake adding those needed libraries but it still failed to compile TwoJointMain.cpp. From close investigations on CMakeLists.txt on TwoJointMain.cpp, it appeared that it also needed internal source files in the bullet3 repository like example/SharedMemory/PhysicsClient.cpp and so on. In this case, do you guys have any idea to include these internal sources via CMake in other project?

Thank you in advance.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Bullet as an external library

Post by drleviathan »

TwoJoint is a stand-alone executable that uses the example utility code to make an in-process "physics server". In a while loop it submits "commands" to the server, steps the server, then harvests the results through the finite set of "handles" to its known demo objects.

If you want to use the same pattern as the Bullet examples then yes, you would need all of the example utils. The easiest way to do that would be to:

(1) download full Bullet source code
(2) add a YourCustomDemo to the other demos, following the coding patterns you see there
(3) build Bullet with examples, which will happen to also build YourCustomDemo

Alternatively:

(1) download the Bullet source code
(2) build it in a known location
(3) write custom CMake in "YourProject" to find the standard Bullet libs AND the example utils where they were built

However, if your C++ project isn't going to look like the Bullet examples at all, and you want to configure it such that other devs can easily download, build, and contribute... then you could just use the official Bullet API to do your bidding and only use the examples stuff as what they are: examples of how it might be done. I guess this option would be called "roll your own 'game engine' which happens to use Bullet for its physics simulation".
bangsh0718
Posts: 3
Joined: Thu Feb 21, 2019 2:48 am

Re: Bullet as an external library

Post by bangsh0718 »

Hello,

Thank you for your reply, but I have a question.

I would like to try the alternative method that you mentioned, but the problem is that example utils are not built in default.
What I mean is, if you see the '''TwoJoint.main"', it target links the individual example utils cpp file when it is built.

In your statement, "(3) write custom CMake in "YourProject" to find the standard Bullet libs AND the example utils where they were built", do you mean I also need to write custom CMake to build the example utils?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Bullet as an external library

Post by drleviathan »

What OS are you using?

My main OS is linux and the build_cmake_single.sh script works for me. It builds all of the libs and examples. When it is done I have an actual executable file and a symbolic link to it:

Code: Select all

build_cmake/examples/TwoJoint/App_TwoJoint-2.88
build_cmake/examples/TwoJoint/App_TwoJoint -> App_TwoJoint-2.88
CMake is supposed to be cross platform so I would expect some success using the same script on Mac. Dunno about Windows.