ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

undefined reference to nlopt

asked 2016-11-14 10:29:53 -0500

rchml gravatar image

updated 2016-11-17 08:36:45 -0500

I use sudo apt-get install libnlopt-dev to install nlopt lib. when i catkin_make in my pc, report says like bellow, like can't link the lib. i donot know how to fix the problem.

this is the report.

alex@ubuntu:~/planner_examples_ws$ catkin_make
Base path: /home/alex/planner_examples_ws
Source space: /home/alex/planner_examples_ws/src
Build space: /home/alex/planner_examples_ws/build
Devel space: /home/alex/planner_examples_ws/devel
Install space: /home/alex/planner_examples_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/alex/planner_examples_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/alex/planner_examples_ws/build"
####
[  0%] [  0%] Built target geometry_msgs_generate_messages_cpp
Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_lisp
[  0%] [  0%] Built target _gridmapping_msgs_generate_messages_check_deps_GridObstacleUpdate
Built target _gridmapping_msgs_generate_messages_check_deps_GridPoint
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target geometry_msgs_generate_messages_py
[  1%] Built target circular_curve_lib
[  4%] Built target alglib
[  4%] Built target gdal_utils
[  6%] Built target math_utils
[  6%] Built target boostrand1
[  6%] Built target random_points1
[  7%] Built target stupidrand1
[  7%] Built target rosparam_util_getvector
[  7%] Built target std_msgs_util
[ 12%] Built target sbpl
[ 12%] Built target nav_msgs_generate_messages_lisp
[ 12%] Built target _tictoc_profiler_generate_messages_check_deps_ProfilerEntry
[ 12%] Built target _ca_nav_msgs_generate_messages_check_deps_PathXYZVPsi
[ 12%] Built target _ca_nav_msgs_generate_messages_check_deps_PathXYZ
[ 12%] Built target _ca_nav_msgs_generate_messages_check_deps_XYZVPsi
[ 12%] Built target _ca_nav_msgs_generate_messages_check_deps_XYZVViewPoint
[ 39%] Built target ompl
[ 39%] Built target _ca_nav_msgs_generate_messages_check_deps_PathXYZVViewPoint
[ 39%] Built target nav_msgs_generate_messages_cpp
[ 39%] Built target nav_msgs_generate_messages_py
[ 39%] Built target _ca_nav_msgs_generate_messages_check_deps_LookAheadTime
[ 44%] Built target mesh_loader_3ds
[ 44%] Built target _ca_nav_msgs_generate_messages_check_deps_WorkspaceTrajectory
[ 44%] Built target pcl_util_examples
[ 45%] Built target pcl_util_pc2_iterator_examples
[ 45%] Built target pcl_util_rgb
[ 45%] Built target scrollgrid_examples
[ 45%] Built target tf_utils
[ 45%] Built target _shapes_generate_messages_check_deps_PolygonDepth
[ 45%] Built target _shapes_generate_messages_check_deps_Point2D
[ 45%] Built target _speed_profile_generate_messages_check_deps_SpeedProfile
[ 45%] Built target _shapes_generate_messages_check_deps_PolygonWithHolesDepth
[ 45%] Built target gridmapping_msgs_generate_messages_cpp
[ 46%] Built target gridmapping_msgs_generate_messages_lisp
[ 47%] Built target gridmapping_msgs_generate_messages_py
[ 48%] Built target alglib_minqp_d_bc1
[ 48%] [ 48%] Built target alglib_example_df
Built target circular_curve_lib_example_dubins_path_set
[ 51%] [ 51%] Built target gdal_utils_example_dem
Built target circular_curve_lib_example_trochoid
[ 51%] Built target ompl_GeometricCarPlanning
[ 51%] Built target math_utils_scratch
[ 52%] Built target ompl_HybridSystemPlanning
[ 52%] [ 52%] Built target ompl_HypercubeBenchmark
Built target ompl_KinematicChainBenchmark
[ 52%] Built target ompl_OptimalPlanning
[ 53%] Built target ompl_PlannerData
[ 53%] [ 53%] Built target ompl_PlannerProgressProperties
[ 53%] Built target ompl_RigidBodyPlanning
Built target ompl_Point2DPlanning
[ 54%] [ 54%] Built target ompl_RigidBodyPlanningWithControls
[ 54%] Built target ompl_RigidBodyPlanningWithIK
Built target ompl_RigidBodyPlanningWithIntegrationAndControls
[ 54%] Built target ompl_RigidBodyPlanningWithODESolverAndControls
[ 55%] [ 55%] [ 55%] Built target ompl_StateSampling
Built target test_adjacency_list
Built target ompl_state_example
[ 55%] Built target test_sbpl
[ 55%] Built target tictoc_profiler_generate_messages_cpp
[ 55%] [ 55%] [ 56%] Built target tictoc_profiler_generate_messages_py
Built target std_msgs_util_load_pose
Built target tictoc_profiler_generate_messages_lisp
[ 58%] [ 60%] Built target ca_nav_msgs_generate_messages_lisp
Built target ca_nav_msgs_generate_messages_cpp
[ 62%] Built target ca_nav_msgs_generate_messages_py
[ 63%] Built target mesh_loader_3ds_example
[ 64%] Built target shapes_generate_messages_cpp
[ 65%] Built target shapes_generate_messages_py
[ 66%] Built target shapes_generate_messages_lisp
[ 67%] Built target tf_utils_transform_vector
[ 67%] Built target speed_profile_generate_messages_cpp
[ 67%] [ 68%] Built target speed_profile_generate_messages_lisp
Built target speed_profile_generate_messages_py
[ 68%] Built target gridmapping_msgs_generate_messages
[ 68%] Built target tictoc_profiler
[ 68%] [ 68%] Built target tictoc_profiler_generate_messages
Built target ca_nav_msgs_generate_messages
[ 68%] Built target shapes_generate_messages
[ 68%] [ 68%] Built target speed_profile_generate_messages
Built target tictoc_profiler_example
[ 68%] Built target ca_nav_msgs_trajectory_converter
[ 68%] Built target ca_nav_msgs_trajectory_converter_example
[ 68%] Built target distancemap2
[ 72%] Built target shapes
[ 73%] Built target distancemap2_3d_obst_test
[ 73%] Built target shapes_cgal_complement
[ 73%] Built target distancemap2_subscribe_to_grid
[ 73%] Built target shapes_bbox_shape_example
[ 74%] Built target shapes_cgal_connect_holes
[ 74%] Built target shapes_cgal_difference
[ 74%] Built target shapes_cgal_multiple_holes
[ 74%] Built target shapes_cgal_nested_triangulation
[ 74%] [ 75%] Built target shapes_cgal_polygon_join_intersect
Built target shapes_cgal_polygon_intersection
[ 75%] Built ...
(more)
edit retag flag offensive close merge delete

Comments

Please use the Preformatted Text button (the one with 101010 on it) next time when copying console text into your question. It makes things much easier to read. Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-14 10:53:35 -0500 )edit

ok, i'm sorry, first time to make a question.

rchml gravatar image rchml  ( 2016-11-14 11:11:56 -0500 )edit

This is most likely an issue with your CMakeLists.txt. Please update question and add that file. I haven't used nlopt much, but I was able to compile an example I had lying around with CMake by specifically appending path to SO file like the following:

jarvisschultz gravatar image jarvisschultz  ( 2016-11-14 17:56:48 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-11-17 14:15:37 -0500

rchml gravatar image

oh, let me end my problem.(get help from labmate) int the cmakelists.txt , focus on the last line. the project_namemeans my findnlopt.cmake works no results. you can change it with ${NLOPT_LIBRARIES} now, it works well. or in the terminal: 5.catkin_make clean and. rm -Rf devel/ build/

which also works. it's just a demo to show the related problems. thanks upfloor guy.

 ## Declare a cpp library
    add_library(${PROJECT_NAME} 
    src/dubins_z_state_space.cpp 
    src/curvature_bvp_solver.cpp 
    src/clothoid_state_space.cpp 
    src/dubins_feasible_path_generator.cpp 
    src/clothoid_z_state_space.cpp
    src/glideslope_bvp_solver.cpp)
    target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${NLOPT_LIBRARIES})

    ## Declare a cpp executable
    add_executable(${PROJECT_NAME}_example_dubins_z_path examples/example_dubins_z_path.cpp)
    target_link_libraries(${PROJECT_NAME}_example_dubins_z_path ${PROJECT_NAME} ${catkin_LIBRARIES})
edit flag offensive delete link more
2

answered 2016-11-14 17:59:14 -0500

updated 2016-11-15 10:33:28 -0500

On my system, the nlopt version from apt-get has its headers and libs automatically installed to directories where CMake can find them. Therefore I can get away without using find_package at all and instead directly use target_link_libraries. This isn't very portable, but it will likely solve your issue. In general, you'd likely be better off writing a FindNLOPT.cmake file, but this might also require writing a NLOPTConfig.cmake file (I'm no expert on writing those files, but it seems complicated to get versions that work well on all systems). The following CMakeLists.txt file builds a simple nlopt demo for me.

cmake_minimum_required (VERSION 2.6)

project(nlopt_test)

add_executable(demo example.cpp)
target_link_libraries(demo nlopt)

Perhaps that will help you sort out your errors.

edit flag offensive delete link more

Comments

thank you very much, i update the CMakeLists.txt.

rchml gravatar image rchml  ( 2016-11-15 08:28:38 -0500 )edit

Thanks for converting this to an answer.... I went ahead and edited it to make it more useful as an answer.

jarvisschultz gravatar image jarvisschultz  ( 2016-11-15 10:33:52 -0500 )edit

i found a findnlopt.cmake file, but do not know how to use it. maybe i should to contact to the project writer.

rchml gravatar image rchml  ( 2016-11-17 08:38:49 -0500 )edit

Thanks! It really works!

Rocknz gravatar image Rocknz  ( 2018-11-14 00:50:33 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-14 10:29:53 -0500

Seen: 2,102 times

Last updated: Nov 17 '16