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

link ncurses ROS kinetic

asked 2017-02-20 15:13:43 -0500

matt27110 gravatar image

Hello everyone !

I know there are already posts about this subject but after many tries I don't know how to resolve this problem.

This is my code "test_ncurses.cpp":

// test_ncurses.cpp
#include <ncurses.h>
int main(int argc, char **argv) 
{   
   initscr();    
   printw("Hello world");  
   refresh();    
   getch();    
   endwin();   
   return 0; 
}

In the manifest I added these lines :

<build_depend>ncurses++</build_depend>
<run_depend>ncurses++</run_depend>

And in my CMakeLists.txt :

find_package( PkgConfig REQUIRED )
pkg_check_modules ( ncurses++ REQUIRED ncurses++ )
add_executable(test_ncurses src/test_ncurses.cpp )
target_link_libraries(test_ncurses ${catkin_LIBRARIES}  ${ncurses++_LIBRARIES})

And when I want to catkin_make my project I get errors :

undefined reference to "initscr"
undefined reference to "printw"
undefined reference to "refresh"
undefined reference to "stdscr"
undefined reference to "wgetch"
undefined reference to "endwin"

Do you have any ideas ?

Thank you in advance !

edit retag flag offensive close merge delete

Comments

I'm not sure, but I can imagine that a + is not a valid character in a CMake identifier. See cmake-language - Syntax.

Can you try using pkg_check_modules ( ncurses++ REQUIRED ncursespp) and see if that changes anything?

gvdhoorn gravatar image gvdhoorn  ( 2017-02-21 01:53:04 -0500 )edit

Not working :/

CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:367 (message):
  A required package was not found
matt27110 gravatar image matt27110  ( 2017-02-21 06:23:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-02-21 06:31:08 -0500

matt27110 gravatar image

Eureka !!

I removed the 2 lines in the manifest and the pkg_check_modules in the CMakeLIsts. Then I replaced ncurses++ by Curses and it works !

find_package(Curses REQUIRED)
add_executable(test_ncurses src/test_ncurses.cpp )
target_link_libraries(test_ncurses ${catkin_LIBRARIES}  ${Curses_LIBRARIES})
edit flag offensive delete link more

Comments

Curses is indeed the name of the find script that CMake uses with ncurses. See also cmake-modules(7) - Curses.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-21 07:46:53 -0500 )edit

On Ubuntu 16.04 with Kinetic, it's ${CURSES_LIBRARIES} (all uppercase). You can see it in the heading of /usr/share/cmake-3.5/Modules/FindCurses.cmake.

Avio gravatar image Avio  ( 2018-07-06 08:06:15 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-20 15:13:43 -0500

Seen: 1,046 times

Last updated: Feb 21 '17