Ask Your Question
1

How to link ncurses.h library in CMakeLists.txt? [closed]

asked 2014-07-25 16:13:39 -0600

randylewis7 gravatar image

Hello, I am currently attempting to repackage a C++ device driver into a ROS node that will accomplish the same thing. However, the project is dependent on the ncurses library, and I am apparently not correctly linking the library, because I am getting a bunch of undefined reference errors to functions that, in the code are comment-labeled as coming from the ncurses library. How do I properly link this library in my CMakeLists file? This is what I have right now, but its not working:

add_executable(steering_keyboard_node src/steering_keyboard_node.cpp include/steeringKeyboard/workmanComm.cpp include/steeringKeyboard/workmanParams.cpp include/steeringKeyboard/ /usr/include/ncurses.h /usr/include/curses.h)
target_link_libraries(steering_keyboard_node ${catkin_LIBRARIES})
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by randylewis7
close date 2014-07-28 11:24:39.126515

Comments

Please show the errors you are getting and provide enough information on how to reproduce the problem. . Otherwise we have to guess what you are doing wrong.

tfoote gravatar imagetfoote ( 2014-07-26 14:26:36 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-26 19:34:15 -0600

vitor.ecomp gravatar image

updated 2014-07-26 23:14:28 -0600

ahendrix gravatar image

Some time ago i has the same problem, but on ros fuerte version with rosbuild, maybe the solution still working my solution consist on add: <rosdep name="ncurses++"/> to the manifest and on the CMakeLists something like that

find_package( PkgConfig REQUIRED )
pkg_check_modules ( ncurses++ REQUIRED ncurses++ )

rosbuild_add_executable(vant    
    src/....cpp
    src/....cpp
)
rosbuild_genmsg ()

target_link_libraries ( vant ${ncurses++_LIBRARIES})

sorry for my english.

edit flag offensive delete link more

Comments

Note that these instructions are for rosbuild. For cakin, change <rosdep> to <build_depend>ncurses++</build_depend> and rosbuild_add_executable to add_executable

ahendrix gravatar imageahendrix ( 2014-07-26 23:16:19 -0600 )edit

Thanks guys, adding build and run depend to my package.xml: <build_depend>ncurses++</build_depend> <run_depend>ncurses++</run_depend> braries and adding ${ncurses++_LIBRARIES} into my CMakeLists target_link_libraries line solved the problem.

randylewis7 gravatar imagerandylewis7 ( 2014-07-28 11:24:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-07-25 16:13:39 -0600

Seen: 1,188 times

Last updated: Jul 26 '14