I want to use the Bullet library only for collision detection between two convex hulls. My problem is how to link the library in my project and specify that in the CMakeLists.txt.
I don't really understand how to install the Bullet library. I cloned the repo in a folder, created a build folder, compiled it with cmake and installed it. I tried to link the library to my project by adding in the CMakeLists.txt:
find_package( Bullet REQUIRED )
/usr/bin/ld: /usr/local/lib/libBulletDynamics.a(btTypedConstraint.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
You need to compile Bullet library with
-fPIC, as linker's error message says.
Either configure this library with CMake variable BUILD_SHARED_LIBS set:
cmake -DBUILD_SHARED_LIBS=on <source-dir>
or with CMake variable CMAKE_POSITION_INDEPENDENT_CODE set:
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on <source-dir>
The first way you will get shared libraries, which always have
-fPIC flag enabled, the second way you will compile libraries statically, but with given flag explicitely set.