ros / urdf

Repository for URDF parsing code
63 stars 41 forks source link

CMake error with the latest urdfdom #37

Open FederAndInk opened 2 years ago

FederAndInk commented 2 years ago

With the latest version of urdfdom (3.0.0) I get this CMake error when trying to compile joint-limits-interface:

-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: .cache/yay/ros-noetic-joint-limits-interface/src/build/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /usr/bin/python (found suitable version "3.9.7", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using default Python package layout
-- Found PY_em: /usr/lib/python3.9/site-packages/em.py  
-- Using empy: /usr/lib/python3.9/site-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Skip enable_testing() when building binary package
-- Using CATKIN_TEST_RESULTS_DIR: .cache/yay/ros-noetic-joint-limits-interface/src/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found Python: /usr/bin/python3.9 (found version "3.9.7") found components: Interpreter 
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests-3.9
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
CMake Error at /opt/ros/noetic/share/urdf/cmake/urdfConfig.cmake:173 (message):
  Project 'joint_limits_interface' tried to find library
  '$<$<NOT:$<CONFIG:Debug>>:/usr/lib/liburdfdom_sensor.so>'.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'urdf'? Did you find_package() it before the subdirectory containing its
  code is included?
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:5 (find_package)
sloretz commented 2 years ago

Error message comes from:

https://github.com/ros/catkin/blob/7fa3eb3508ba12c34d85b8e54bbdf4bbdc60a5c1/cmake/templates/pkgConfig.cmake.in#L173

It looks like the catkin template for a projectConfig.cmake file is making sure the library exists before adding it to urdf_LIBRARIES in the urdfConfig.cmake, but doesn't know what to do with a library inside of a generator expression. Probably a good fix is to make catkin add the library to the variable anyways when it looks like a generator expression (contains $< might be a good heuristic)

TeeKups commented 2 years ago

Simply deleting the generator expressions from line 119 of /opt/ros/noetic/share/urdf/cmake/urdfConfig.cmake seems to have fixed the problem for me -- or at least ros-noetic-desktop-full installed without errors from AUR.

I don't know much about Cmake so I don't know what kind of implications it might have in the long run, but it might work as a quick fix until a proper solution is found.

Maik93 commented 2 years ago

Removing line 119 does not work for me: ros-noetic-kdl-parser-1.14.1 cannot be build correctly without it. The encountered error when trying it is:

/usr/bin/ld: devel/lib/libkdl_parser.so: undefined reference to `urdf::Model::initParam(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
felixkol commented 2 years ago

I had the same error today. The libraries set in the cmake file do exist in my /usr/lib. Seems like the generator expressions are just not working. After removing them, installation is progressing normal.

In conclusion, replacing line 119 with

set(libraries "urdf;/usr/lib/liburdfdom_sensor.so;/usr/lib/liburdfdom_model_state.so;/usr/lib/liburdfdom_model.so;/usr/lib/liburdfdom_world.so;/usr/lib/libconsole_bridge.so.1.0;/usr/lib/libboost_thread.so.1.76.0;/usr/lib/libtinyxml.so;/usr/lib/libtinyxml2.so")

works for me.

asschmidt commented 2 years ago

I had the same error today. The libraries set in the cmake file do exist in my /usr/lib. Seems like the generator expressions are just not working. After removing them, installation is progressing normal.

In conclusion, replacing line 119 with

set(libraries "urdf;/usr/lib/liburdfdom_sensor.so;/usr/lib/liburdfdom_model_state.so;/usr/lib/liburdfdom_model.so;/usr/lib/liburdfdom_world.so;/usr/lib/libconsole_bridge.so.1.0;/usr/lib/libboost_thread.so.1.76.0;/usr/lib/libtinyxml.so;/usr/lib/libtinyxml2.so")

works for me.

That fix also worked for me. I just replaced line 119 with the proposal of @felixkol

j-rivero commented 2 years ago

Hello! I'm trying to reproduce the problem but I failed. I've created a workspace with urdfdom (master branch) and urdf (melodic-devel branch) and I was not able to trigger the problem. Removing urdfdom from the colcon workspace did not help either. May I ask: which kind of installation are you using? Thanks!

felixkol commented 2 years ago

@j-rivero I'm running arch linux. The error occured using this AUR package. I think the error occured installing this or this dependencie. Since the build is running for hours now I can't verify it.

asschmidt commented 2 years ago

@j-rivero I think I ran into the same situation as @felixkol because I'm also using Arch Linux and the error occurred during the AUR package installation with the command yay -S ros-noetic-desktop-full. Unfortunately my build is still running so I cannot verify anything yet.

Maik93 commented 2 years ago

I'm on Archlinux too. My fix is to checkout urdfdom to version 1.0.4 and packages stated by @felixkol compile correctly.

j-rivero commented 2 years ago

Could anyone point me to a full build log in Arch or other failing platform? I'm unable to reproduce it in Ubuntu Focal using colcon or catkin compiling the sources: urdfdom (master branch), urdf (melodic-devel branch) and joint_limits_interface (noetic-devel).

FederAndInk commented 2 years ago

Well, I already posted the whole build output, what's your CMake version? Maybe it's coming from there?

There is also the pkgbuild that's worth checking: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ros-noetic-joint-limits-interface

FederAndInk commented 2 years ago

Ok, I just have a question, are you sure generator expression are allowed in find_library? I don't know for sure, I think they are allowed only in target_* and other few functions

Edit: Ok, I'm just tired, that's in the comment above, the catkin template should just ignore generator expression

AchmadFathoni commented 2 years ago

AUR's ros-noetic-urdf now patched with sed -i '119s@\$<\$<\(NOT:\$<\)*CONFIG:Debug>*>:@@g' urdfConfig.cmake and package which depend on it can be compiled with urdfdom 3.0.0

xlla commented 2 years ago

how to fix this ugly judgement permanently? if I upgrade some depend lib and rebuild ros, this error occurs again.

xlla commented 2 years ago

hi, @AchmadFathoni , your sed command just remove the prefix of lib regex expression and leave suffix ">" there. I manage to add some extra filter in cmake files to remove those expression automatic if exist. please ref here

rhaschke commented 1 year ago

I'm unable to reproduce it in Ubuntu Focal using colcon or catkin

@j-rivero, the issue is triggered only if both release and debug versions of the liburdfdom_*.so libraries are found: https://github.com/ros/urdfdom/blob/master/cmake/urdfdom-config.cmake.in#L20-L22 Thus, creating a symlink e.g. from liburdfdom_model.so to liburdfdom_modeld.so triggers the problem in Focal as well.

I filed a PR to fix this issue: https://github.com/ros/catkin/pull/1181