moveit / geometric_shapes

Representation of geometric shapes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linking to assimp fails on mac 10.10

Juxi opened this issue · comments

I am trying to compile ros on mac
When trying to building I get the following error:

[100%] Building CXX object CMakeFiles/geometric_shapes.dir/src/body_operations.cpp.o
Linking CXX shared library devel/lib/libgeometric_shapes.dylib
/usr/local/Cellar/cmake/3.0.2/bin/cmake -E cmake_link_script CMakeFiles/geometric_shapes.dir/link.txt --verbose=1
/usr/bin/c++  -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -dynamiclib -Wl,-headerpad_max_install_names   -o devel/lib/libgeometric_shapes.dylib -install_name /Users/xxx/ros_catkin_ws/build_isolated/geometric_shapes/devel/lib/libgeometric_shapes.dylib CMakeFiles/geometric_shapes.dir/src/shapes.cpp.o CMakeFiles/geometric_shapes.dir/src/shape_operations.cpp.o CMakeFiles/geometric_shapes.dir/src/mesh_operations.cpp.o CMakeFiles/geometric_shapes.dir/src/bodies.cpp.o CMakeFiles/geometric_shapes.dir/src/body_operations.cpp.o  -L/Users/xxx/ros_catkin_ws/install_isolated/lib -lassimp /usr/local/lib/libqhull.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libroscpp_serialization.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/librostime.dylib /usr/local/lib/libboost_date_time-mt.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libcpp_common.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/libconsole_bridge.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libresource_retriever.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libshape_tools.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/librandom_numbers.dylib /usr/local/lib/libconsole_bridge.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_filesystem-mt.dylib /usr/local/lib/libboost_thread-mt.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libresource_retriever.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/libshape_tools.dylib /Users/xxx/ros_catkin_ws/install_isolated/lib/librandom_numbers.dylib /usr/local/lib/libboost_filesystem-mt.dylib -Wl,-rpath,/Users/xxx/ros_catkin_ws/install_isolated/lib 
ld: library not found for -lassimp

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [devel/lib/libgeometric_shapes.dylib] Error 1
make[1]: *** [CMakeFiles/geometric_shapes.dir/all] Error 2
make: *** [all] Error 2
<== Failed to process package 'geometric_shapes': 
  Command '/Users/xxx/ros_catkin_ws/install_isolated/env.sh make -j4 -l4' returned non-zero exit status 2

Reproduce this error by running:
==> cd /Users/xxx/ros_catkin_ws/build_isolated/geometric_shapes && /Users/xxx/ros_catkin_ws/install_isolated/env.sh make -j4 -l4

any idea why libassimp.dylib is not found?
it's installed with brew

> ls -h /usr/local/lib/libassimp.dylib 
... /usr/local/lib/libassimp.dylib -> ../Cellar/assimp/3.1.1/lib/libassimp.dylib

On a related note, the assimp version check in CMakeLists.txt failed for me on Yosemite with the latest brew assimp (also with --HEAD which is 3.1.1)

This issue is old - was a solution found or is it still a problem? Can it be closed?

I have the same issue with ROS Kinetic, OSX 10.11.6 and assimp-3.3.1.
Location of lib: /usr/local/lib/libassimp.dylib

Fix:

  1. Open ~/ros_catkin_ws/build_isolated/geometric_shapes/CMakeFiles/geometric_shapes.dir/link.txt
  2. Replace -lassimp with /usr/local/lib/libassimp.dylib.

geometric_shapes simply uses a system provided cmake module or otherwise pkg-config. If that results in linking errors it sounds like there is a problem with the way Assimp is packaged by homebrew.

I had the same issue with Kinetic, OS X 10.12.5 and assimp 3.3.1.
I used the fix by @argrento which worked for me.

Just to follow this up here with some relevant links:

Homebrew formula: https://github.com/Homebrew/homebrew-core/blob/master/Formula/assimp.rb

Find module from upstream: https://github.com/assimp/assimp/blob/master/cmake-modules/Findassimp.cmake

Certainly the find_library portion of the module looks pretty bog-standard to me:

https://github.com/assimp/assimp/blob/92046319be744fa514d643bab38c57b2c5fbae24/cmake-modules/Findassimp.cmake#L61-L65

Then again, there's also this other config module in the upstream, which is way more sketchy:

https://github.com/assimp/assimp/blob/92046319be744fa514d643bab38c57b2c5fbae24/assimp-config.cmake.in#L50

All in all, the cmake strategy in assimp looks rather haphazard...

Okay, can confirm that I see the issue on my El Cap machine. With the following CMakeLists.txt:

find_package(assimp)
message("xxxx ${ASSIMP_LIBRARIES}")

find_library(
    assimp_LIBRARIES
    NAMES assimp
)
message("yyyy ${assimp_LIBRARIES}")

I have this output:

$ cmake .
xxxx assimp
yyyy /usr/local/lib/libassimp.dylib

So find_library does the right thing, but assimp's hardcoded library name most definitely doesn't.

I'll close this.

All further problems with this should be discussed over at assimp:
assimp/assimp#1517