I have compiled the library from https://github.com/bulletphysics/bullet3 and tested some of the examples, but I can't seem to compile this simple program.
#include <btBulletDynamicsCommon.h>
int main(){
}
I noticed that header file was located in the build_cmake/src directory, so I included it with -I, which worked, but then I had linking errors, so I found the .so files and linked them with the -L option and some globs which removed the linking errors, but I still had warnings. The following command gave me an executable:
g++ -Wall main.cpp -I bullet3/src/ -L bullet3/build_cmake/src/*/*.so
but had the following warnings:
In file included from bullet3/src/btBulletDynamicsCommon.h:38:0,
from main.cpp:3:
bullet3/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h: In constructor ‘btSISolverSingleIterationData::btSISolverSingleIterationData(btAlignedObjectArray<btSolverBody>&, btConstraintArray&, btConstraintArray&, btConstraintArray&, btConstraintArray&, btAlignedObjectArray<int>&, btAlignedObjectArray<int>&, btAlignedObjectArray<int>&, btAlignedObjectArray<btTypedConstraint::btConstraintInfo1>&, btScalar (*&)(btSolverBody&, btSolverBody&, const btSolverConstraint&), btScalar (*&)(btSolverBody&, btSolverBody&, const btSolverConstraint&), btScalar (*&)(btSolverBody&, btSolverBody&, const btSolverConstraint&), btAlignedObjectArray<int>&, long unsigned int&, int&, int&)’:
bullet3/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h:49:29: warning: ‘btSISolverSingleIterationData::m_kinematicBodyUniqueIdToSolverBodyTable’ will be initialized after [-Wreorder]
btAlignedObjectArray<int>& m_kinematicBodyUniqueIdToSolverBodyTable;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bullet3/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h:44:17: warning: ‘long unsigned int& btSISolverSingleIterationData::m_seed’ [-Wreorder]
unsigned long& m_seed;
^~~~~~
bullet3/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h:57:2: warning: when initialized here [-Wreorder]
btSISolverSingleIterationData(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And when I ran the executable I got an error:
./a.out: error while loading shared libraries: libBullet3Dynamics.so.2.88: cannot open shared object file: No such file or directory
I attempted to add the file to my LD path:
export LD_LIBRARY_PATH=/home/sam/code/bullet/bullet3/build_cmake/src/Bullet3Common/libBullet3Common.so.2.88:$LD_LIBRARY_PATH
But got the same error.
It seems like I'm over-complicating this, but I can't seem to find any examples online of how to compile a program like this...
Edit:
I'm on Debian Linux.
Edit 2:
Output of ldd:
linux-vdso.so.1 (0x00007ffdecb04000)
libBullet3Common.so.2.88 => /home/sam/code/bullet/bullet3/build_cmake/src/Bullet3Common/libBullet3Common.so.2.88 (0x00007fd0246e7000)
libBullet3Dynamics.so.2.88 => not found
libBullet3Geometry.so.2.88 => not found
libBullet3OpenCL_clew.so.2.88 => not found
libBulletCollision.so.2.88 => not found
libBulletDynamics.so.2.88 => not found
libBulletInverseDynamics.so.2.88 => not found
libBulletSoftBody.so.2.88 => not found
libLinearMath.so.2.88 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd024365000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd024061000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd023e4a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd023aab000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd024aee000)
Looks pretty good, however LD_LIBRARY_PATH
should be pointing to directories, not library files themselves.
So try change the LD_LIBRARY_PATH command to:
export LD_LIBRARY_PATH=/home/sam/code/bullet/bullet3/build_cmake/src/Bullet3Common/:$LD_LIBRARY_PATH
after edit:
So looking at the output from ldd, it shows that it can't find several libraries it requires.
Make sure these are all findable on your LD_LIBRARY_PATH