0
$\begingroup$

Rosanswers logo

Hi,

I want to use two external libraries:

In my qt project, I added

LIBS += -lCGAL -lgmp

to my .pro file and it works well.

When I try to use it in my ros project, I tried

find_library(CGAL_LIBRARY CGAL /usr/local)
find_library(GMP_LIBRARY gmp /usr/lib)

target_link_libraries(ros_project ${CGAL_LIBRARY} ${GMP_LIBRARY} )

Its seems that the CGAL library is linked correctly, but the GMP library is not. I get the following error for example:

error: undefined reference to `__gmpq_init'

Taking a look at the "CMakeCache.txt" in the ros project folder shows:

########################
# EXTERNAL cache entries
########################

//Path to a library.
CGAL_LIBRARY:FILEPATH=/usr/local/lib/libCGAL.so

//Path to a library.
GMP_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libgmp.so

The command sudo dpkg -L libgmp-dev shows:

/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libgmp.a
/usr/lib/x86_64-linux-gnu/libgmpxx.a
/usr/include
/usr/include/gmp.h
/usr/include/gmpxx.h
/usr/include/gmp-x86_64.h
/usr/share
/usr/share/doc
/usr/share/doc/libgmp-dev
/usr/share/doc/libgmp-dev/NEWS.gz
/usr/share/doc/libgmp-dev/AUTHORS
/usr/share/doc/libgmp-dev/README
/usr/share/doc/libgmp-dev/copyright
/usr/lib/x86_64-linux-gnu/libgmp.so
/usr/lib/x86_64-linux-gnu/libgmpxx.so
/usr/share/doc/libgmp-dev/changelog.Debian.gz

so I guess the path is found correctly and I have absolutely no idea why I get the undefined reference. I'am using Ubuntu 12.04 64bit. Does anyone have an idea how to solve this?

Thanks in advance

Hendrik

Edit:

grep --color -Ri "gmp" ./build:

./build/CMakeCache.txt:GMP_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libgmp.so

./build/CMakeFiles/basic_shapes.dir/build.make:../bin/basic_shapes: /usr/lib/x86_64-linux-gnu/libgmp.so

./build/CMakeFiles/basic_shapes.dir/link.txt:/usr/bin/c++ -O2 -g -pthread CMakeFiles/basic_shapes.dir/src/basic_shapes.o CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/trackGenerator/trackGenerator/src/trackGenerator.o -o ../bin/basic_shapes -rdynamic -L/opt/ros/fuerte/lib -L/usr/local/boost_1_51_0/stage/lib -L/usr/local/lib -L/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/trackGenerator/build_lib -L/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/getVoronoi/build_lib -lroscpp -lrostime -lrosconsole -lroscpp_serialization -lxmlrpcpp /usr/local/boost_1_51_0/stage/lib/libboost_system.a /usr/local/boost_1_51_0/stage/lib/libboost_thread.a /usr/local/lib/libCGAL.so -lgmp /media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/trackGenerator/build_lib/libtrackGenerator.a /media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/getVoronoi/build_lib/libgetVoronoi.a -Wl,-rpath,/opt/ros/fuerte/lib:/usr/local/lib

Binary file ./build/CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/trackGenerator/trackGenerator/src/trackGenerator.o matches

Binary file ./build/CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/voronoi/src/AlphaShape.o matches

Binary file ./build/CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/voronoi/src/DPLineSimplification.o matches

Binary file ./build/CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/voronoi/src/PolygonEnvironment.o matches

Binary file ./build/CMakeFiles/basic_shapes.dir/media/truecrypt1/coding/Cpp/MastersThesis/logplan2013_code/voronoi/src/VoronoiDiagram.o matches

Binary file ./build/CMakeFiles/basic_shapes.dir/src/basic_shapes.o matches

Occurrence of gmp is marked bold. Before the third and last occurrence of gmp, the path to the working library libCGAL.so is given, but for gmp only -lgmp, is this part of the problem?

Mani you said: "Please check all occurrences in Makefiles to make sure the build system is doing its job correctly". Where has gmp to occur when the build System has done the job correctly?

Edit2:

Using find_package(GMP REQUIRED) in CMakeLists.txt results in following:

CMake Warning at CMakeLists.txt:55 (find_package):
  Could not find module FindGMP.cmake or a configuration file for package
  GMP.

  Adjust CMAKE_MODULE_PATH to find FindGMP.cmake or set GMP_DIR to the
  directory containing a CMake configuration file for GMP.  The file will
  have one of the following names:

    GMPConfig.cmake
    gmp-config.cmake


[rosbuild] Including /opt/ros/fuerte/share/roscpp/rosbuild/roscpp.cmake
[rosbuild] Including /opt/ros/fuerte/share/rospy/rosbuild/rospy.cmake
[rosbuild] Including /opt/ros/fuerte/share/roslisp/rosbuild/roslisp.cmake
[rosbuild] Building package sendPgmMarker
-- Configuring done
-- Generating done

I couldn't find a file named GMPConfig.cmake or gmp-config.cmake. I used the ubuntu repositories to install gmp.


Originally posted by henge266 on ROS Answers with karma: 1 on 2012-10-19

Post score: 0


Original comments

Comment by Mani on 2012-10-19:
One more step to debug is to run grep --color -Ri "gmp" ./build in your package folder. Please check all occurrences in Makefiles to make sure the build system is doing its job correctly

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I guess you need to use find_package instead of find_library in your CMakeList.txt:

Link

http://stackoverflow.com/a/6980807/1215297


Originally posted by Mani with karma: 1704 on 2012-10-19

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by tfoote on 2013-01-14:
You may have to use pkg-config as well. There's a FindPkgConfig module.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.