Ask Your Question

How to link ncurses.h library in CMakeLists.txt?

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

mysteriousmonkey29 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 close merge delete


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 image tfoote  ( 2014-07-26 14:26:36 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

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_genmsg ()

target_link_libraries ( vant ${ncurses++_LIBRARIES})

sorry for my english.

edit flag offensive delete link more


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 image ahendrix  ( 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.

mysteriousmonkey29 gravatar image mysteriousmonkey29  ( 2014-07-28 11:24:23 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 1,443 times

Last updated: Jul 26 '14