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

About Raisim Torch Conflict #599

Open
DenizYilmazx opened this issue Jul 11, 2024 · 9 comments
Open

About Raisim Torch Conflict #599

DenizYilmazx opened this issue Jul 11, 2024 · 9 comments

Comments

@DenizYilmazx
Copy link

Hi,

I will implement a RL algorithm with using Raisim. For that I will use libtorch but when I try to link libraries I got error as shown below. I will also add my CMake file.

Both libtorch and raisim are working separately. But when I create my run.cpp file and add launchServer() line, I got similar errors. In this error it seems like, it could not find the raisim library but if I remove torch it works properly.

Is there any conflict between libraries? Thanks in advance.

Sincerely,

"""Error"""

/usr/bin/ld: CMakeFiles/run.dir/src/run.cpp.o: in function raisim::World::exportToXml(std::string const&)': /home/deno/raisimLib/build/include/raisim/World.hpp:107: undefined reference to raisim::World::exportToXml(std::string const&, std::string const&)'
/usr/bin/ld: CMakeFiles/run.dir/src/run.cpp.o: in function raisim::RaisimServer::processRequests()': /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1151: undefined reference to raisim::World::addBox(double, double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1153: undefined reference to raisim::World::addSphere(double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1155: undefined reference to raisim::World::addCylinder(double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1157: undefined reference to raisim::World::addCapsule(double, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1159: undefined reference to raisim::World::addMesh(std::string const&, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1180: undefined reference to raisim::World::addGround(double, std::string const&, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1183: undefined reference to raisim::World::addHeightMap(std::string const&, double, double, double, double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1186: undefined reference to `raisim::World::addArticulatedSystem(std::string const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, unsigned long, unsigned long, raisim::ArticulatedSystemOption)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/run.dir/build.make:102: run] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/run.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

CMakeLists.txt

@jhwangbo
Copy link
Contributor

jhwangbo commented Jul 11, 2024

That is not how you should link raisim. Please check the CMake example here

https://raisim.com/sections/Introduction.html

@DenizYilmazx
Copy link
Author

I changed Cmake to this and raisim works fine.

cmake_minimum_required(VERSION 3.10)
project(franka_project LANGUAGES CXX)

set(CMAKE_PREFIX_PATH "/home/deno/raisimLib/build")

find_package(raisim CONFIG REQUIRED)
find_package(Eigen3 REQUIRED)

include_directories (${EIGEN3_INCLUDE_DIRS})

add_executable(franka src/franka_1.cpp src/Franka_Library/Math_Functions.cpp src/Franka_Library/Kinematics_Dynamics.cpp)
target_link_libraries(franka PUBLIC raisim::raisim pthread)
target_include_directories(franka PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

But when I add necessary lines for torch(shown below), I got an error again.

cmake_minimum_required(VERSION 3.10)
project(franka_project LANGUAGES CXX)

set(CMAKE_PREFIX_PATH "/home/deno/raisimLib/build" ; "/home/deno/libtorch")

find_package(raisim CONFIG REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Torch REQUIRED)

include_directories (${EIGEN3_INCLUDE_DIRS})

add_executable(franka src/franka_1.cpp src/Franka_Library/Math_Functions.cpp src/Franka_Library/Kinematics_Dynamics.cpp)
target_link_libraries(franka PUBLIC raisim::raisim pthread ; "${TORCH_LIBRARIES}")
target_include_directories(franka PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

""Error""

/usr/bin/ld: CMakeFiles/franka.dir/src/franka_1.cpp.o: in function main': /home/deno/deno_ws/src/franka_1.cpp:23: undefined reference to raisim::World::addGround(double, std::string const&, unsigned long)'
/usr/bin/ld: /home/deno/deno_ws/src/franka_1.cpp:25: undefined reference to raisim::World::addArticulatedSystem(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&, unsigned long, unsigned long, raisim::ArticulatedSystemOption)' /usr/bin/ld: CMakeFiles/franka.dir/src/franka_1.cpp.o: in function raisim::World::exportToXml(std::string const&)':
/home/deno/raisimLib/build/include/raisim/World.hpp:107: undefined reference to raisim::World::exportToXml(std::string const&, std::string const&)' /usr/bin/ld: CMakeFiles/franka.dir/src/franka_1.cpp.o: in function raisim::RaisimServer::processRequests()':
/home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1151: undefined reference to raisim::World::addBox(double, double, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1153: undefined reference to raisim::World::addSphere(double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1155: undefined reference to raisim::World::addCylinder(double, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1157: undefined reference to raisim::World::addCapsule(double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1159: undefined reference to raisim::World::addMesh(std::string const&, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1180: undefined reference to raisim::World::addGround(double, std::string const&, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1183: undefined reference to raisim::World::addHeightMap(std::string const&, double, double, double, double, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1186: undefined reference to raisim::World::addArticulatedSystem(std::string const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, unsigned long, unsigned long, raisim::ArticulatedSystemOption)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/franka.dir/build.make:138: franka] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/franka.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

@jhwangbo
Copy link
Contributor

I am not sure what the semi colon and quotation marks do in the target_link_libraries. Can you remove them?

Also can you print out the list "${TORCH_LIBRARIES}"?

@DenizYilmazx
Copy link
Author

I removed the semi colon and quotation marks. the only problem is in the target link libraries. It works fine just with raisim but when I add the Torch to that line, I got the error as "undefined reference". Also in the installation part of the libtorch, (https://pytorch.org/cppdocs/installing.html)

I need to add torch library as this target_link_libraries(example-app "${TORCH_LIBRARIES}").

Find the print of the torch libraries below,

-- raisim:
-- Version: 1.1.7
-- Includes: /home/deno/raisimLib/build/include
-- Libraries: raisim::raisimPng;raisim::raisimODE;raisim::raisimMine;raisim::raisim
-- TORCH_LIBRARIES: torch;torch_library;/home/deno/libtorch/lib/libc10.so;/home/deno/libtorch/lib/libkineto.a
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/deno/deno_ws/build

I also added the updated version of CMake.
CMakeLists.txt

@DenizYilmazx
Copy link
Author


Also when I just #include raisim and use functions as world etc. I can build the project without any error but when I add the line server.launchServer() I got the error that I mentioned below.

/usr/bin/ld: CMakeFiles/franka.dir/src/franka_1.cpp.o: in function raisim::World::exportToXml(std::string const&)': /home/deno/raisimLib/build/include/raisim/World.hpp:107: undefined reference to raisim::World::exportToXml(std::string const&, std::string const&)'
/usr/bin/ld: CMakeFiles/franka.dir/src/franka_1.cpp.o: in function raisim::RaisimServer::processRequests()': /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1151: undefined reference to raisim::World::addBox(double, double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1153: undefined reference to raisim::World::addSphere(double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1155: undefined reference to raisim::World::addCylinder(double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1157: undefined reference to raisim::World::addCapsule(double, double, double, std::string const&, unsigned long, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1159: undefined reference to raisim::World::addMesh(std::string const&, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1180: undefined reference to raisim::World::addGround(double, std::string const&, unsigned long)' /usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1183: undefined reference to raisim::World::addHeightMap(std::string const&, double, double, double, double, double, double, std::string const&, unsigned long, unsigned long)'
/usr/bin/ld: /home/deno/raisimLib/build/include/raisim/RaisimServer.hpp:1186: undefined reference to `raisim::World::addArticulatedSystem(std::string const&, std::string const&, std::vector<std::string, std::allocatorstd::string > const&, unsigned long, unsigned long, raisim::ArticulatedSystemOption)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/franka.dir/build.make:138: franka] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/franka.dir/all] Error 2


@jhwangbo
Copy link
Contributor

jhwangbo commented Jul 12, 2024

set(CMAKE_PREFIX_PATH "/home/deno/raisimLib/build" "/home/deno/libtorch")
why are you adding .../raisimLib/build? You should add .../raisimLib/raisim/linux

@DenizYilmazx
Copy link
Author

Thank you for the correction. I changed it to linux folder but it did not solve my problem. You can find the updated Cmake.
CMakeLists.txt

@Ming-Di
Copy link

Ming-Di commented Sep 6, 2024

Thank you for the correction. I changed it to linux folder but it did not solve my problem. You can find the updated Cmake. CMakeLists.txt

Hi, have you solved this problem yet? I’m facing the same problem now.

@DenizYilmazx
Copy link
Author

Sorry, I could not solve 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

3 participants