Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't link with btWorldImporter #20

Open
jiffygist opened this issue Jan 31, 2024 · 7 comments
Open

Can't link with btWorldImporter #20

jiffygist opened this issue Jan 31, 2024 · 7 comments

Comments

@jiffygist
Copy link

This question was probably asked several times, but I haven't found a working solution.

I configure bullet (latest git version) like this cmake -DCMAKE_INSTALL_PREFIX=/home/herman/prog/build/bullet3-install/ -DBUILD_EXTRAS=ON -DUSE_DOUBLE_PRECISION=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release ... I didn't want to install it to /usr/local/ so it does not interfere with system package manager-installed bullet used for building openmw, that does require double precision, so I chose another location. So there are installed a bunch of .a files in bullet3-install/lib, including libBulletWorldImporter.a

I configure sr3 (latest git version) like this cmake -DCMAKE_BUILD_TYPE=Release -DBULLET_ROOT=/home/herman/prog/build/bullet3-install/ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ..

However this error appears

/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x40): undefined reference to `btWorldImporter::createPlaneShape(btVector3 const&, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x50): undefined reference to `btWorldImporter::createSphereShape(float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x58): undefined reference to `btWorldImporter::createCapsuleShapeX(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x60): undefined reference to `btWorldImporter::createCapsuleShapeY(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x68): undefined reference to `btWorldImporter::createCapsuleShapeZ(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x70): undefined reference to `btWorldImporter::createCylinderShapeX(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x78): undefined reference to `btWorldImporter::createCylinderShapeY(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x80): undefined reference to `btWorldImporter::createCylinderShapeZ(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x88): undefined reference to `btWorldImporter::createConeShapeX(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x90): undefined reference to `btWorldImporter::createConeShapeY(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x98): undefined reference to `btWorldImporter::createConeShapeZ(float, float)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0xe0): undefined reference to `btWorldImporter::createMultiSphereShape(btVector3 const*, float const*, int)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0xf0): undefined reference to `btWorldImporter::createHeightfieldShape(int, int, void const*, float, float, float, int, int, bool)'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/sr-editor3.dir/src/common/SceneObjects.cpp.o:(.data.rel.ro._ZTV17BulletWorldOffset[_ZTV17BulletWorldOffset]+0x168): undefined reference to `btWorldImporter::createGearConstraint(btRigidBody&, btRigidBody&, btVector3 const&, btVector3 const&, float)'

Do I need to disable double precision in bullet? Do I need some changes in its cmake file? Do I need it to use shared libs instead of static? Another bullet version mb? Please help.

@jiffygist
Copy link
Author

jiffygist commented Jan 31, 2024

Output of cmake with find debug mode on is here: log.txt

I find it weird that it first uses the CMake/FindBULLET.cmake file and then also /usr/share/cmake/Modules/FindBullet.cmake which it is not supposed to be using and which has no mention of world importer.

@cryham
Copy link
Member

cryham commented Jan 31, 2024

If I remember right, I didn't use doubles for bullet so yes I advice to disable double precision in docs here.
I saw these errors myself, I think on Windows when building bullet from sources.
This option is USE_DOUBLE_PRECISION in Bullet CMake.

@jiffygist
Copy link
Author

I added message line for module path before finding bullet

#  fix 5  bullet
message(STATUS "module path: " ${CMAKE_MODULE_PATH})
find_package( Bullet REQUIRED )

and it prints /home/herman/prog/build/sr3/Dependencies/Ogre/CMake/Packages. So I guess ogre lib ruined module path and sr3/CMake directory is not searched in. Ok I repeat the line that adds sr3/CMake directory in it

#  fix 5  bullet
message(STATUS "module path: " ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/" ${CMAKE_MODULE_PATH})
find_package( Bullet REQUIRED )

Now the file is still not found, but if I copy CMake/FindBULLET.cmake to CMake/FindBullet.cmake it is found and now world importer is in ${BULLET_LIBRARIES}

@cryham
Copy link
Member

cryham commented Jan 31, 2024

Aah, so it builds okay now?
Does it mean I should rename FindBULLET.cmake to FindBullet.cmake?

@jiffygist
Copy link
Author

jiffygist commented Jan 31, 2024

It still cannot link static libraries in.

When I compile bullet as shared libraries, it gives warnings

/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libBulletDynamics.so.3.20, needed by /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/libBulletWorldImporter.so, may conflict with libBulletDynamics.so.3.26
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libBulletCollision.so.3.20, needed by /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/libBulletWorldImporter.so, may conflict with libBulletCollision.so.3.26
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libBulletFileLoader.so.3.20, needed by /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/libBulletWorldImporter.so, may conflict with libBulletFileLoader.so.3.26
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libLinearMath.so.3.20, needed by /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../lib64/libBulletWorldImporter.so, may conflict with libLinearMath.so.3.26
[100%] Built target stuntrally3

and produces an executable linked to both bullet 3.26 in my bullet3-install/ dir and my system bullet 3.20. Game works now but idk which one it uses.

@jiffygist
Copy link
Author

jiffygist commented Jan 31, 2024

After I changed target_link_libraries( ${EXE} ${BULLET_LIBRARIES} -lBulletWorldImporter ) to target_link_libraries( ${EXE} ${BULLET_LIBRARIES} ) it does not link the system bullet libs anymore. Yay!

Does it mean I should rename FindBULLET.cmake to FindBullet.cmake?

Yes, I think. And make sure this file is found by cmake. If include( CMake/Dependencies/OGRE.cmake ) resets CMAKE_MODULE_PATH mb configure ogre after bullet?

Also I don't know how to deal with this:

add_external_lib(
        BULLET
        bullet3/3.24
        REQUIRED
        FIND_PACKAGE
        CONAN_OPTIONS bullet3:extras=True bullet3:network_support=True
        INTERFACE_NAME Bullet::Bullet
)

This reports Invalid value "OFF" for option SR_USE_BULLET if you rename FindBULLET.cmake->FindBullet.cmake. I just commented this out.

@cryham
Copy link
Member

cryham commented Jan 31, 2024

Okay, yeah current cmake config is somewhat butchered by me to work.
add_external_lib( is I think for Conan, IDK maybe not needed. Or maybe it needs to be BULLET for Conan IDK.
BTW there is a branch there, in which Conan should resolve all deps (and probably builds bullet) it worked for me, I didn't yet merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants