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

Problem using gtk with ROS

asked 2016-02-09 04:51:45 -0500

Adri gravatar image

updated 2016-02-09 15:56:57 -0500

joq gravatar image

Hello everyone.

My problem is when I try to use catkin_make.

I have my catkin_ws in /home/name-of-user/, and inside of it has a file.cpp. This file.cpp has an #include <gtk/gtk.h> in order to make a GUI with gtk. The gtk.h path is /usr/include/gtk-2.0/gtk/.

And here is the problem: When I use catkin_make it shows this error:

[ 75%] /home/name-of-user/catkin_ws/src/package/src/file.cpp:1:21: fatal error: gtk/gtk.h: No such file or directory
 #include <gtk/gtk.h>

compilation terminated.

make[2]: *** [package/CMakeFiles/file.dir/src/file.cpp.o] Error 1

make[1]: *** [package/CMakeFiles/package.dir/all] Error 2
make: *** [all] Error 2

Invoking "make -j2 -l2" failed

Does anyone know how to solve this problem? I think maybe I have to write something in CMakeLists.txt, but I don't know what.

Thank you in advance.

EDIT: Here is the CMakeList.txt that I think I have to modify...

cmake_minimum_required(VERSION 2.8.3)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(randommov src/randommov.cpp)
target_link_libraries(randommov ${catkin_LIBRARIES})
add_dependencies(randommov ${catkin_EXPORTED_TARGETS})

add_executable(randomlaser src/randomlaser.cpp)
target_link_libraries(randomlaser ${catkin_LIBRARIES})
add_dependencies(randomlaser ${catkin_EXPORTED_TARGETS})

add_executable(listenermov src/listenermov.cpp)
target_link_libraries(listenermov ${catkin_LIBRARIES})
add_dependencies(listenermov ${catkin_EXPORTED_TARGETS})

add_executable(interfaz_mejorada src/interfaz_mejorada.cpp)
target_link_libraries(interfaz_mejorada ${catkin_LIBRARIES})
add_dependencies(interfaz_mejorada ${catkin_EXPORTED_TARGETS})
edit retag flag offensive close merge delete


Please edit your question, pasting in the part of your CMakeLists.txt that finds the gtk headers. See: .

joq gravatar image joq  ( 2016-02-09 08:26:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-09 16:00:47 -0500

joq gravatar image

updated 2016-02-09 16:01:17 -0500

You forgot to resolve your system library dependency on gtk.


You'll need some kind of find_package() for gtk, then add the header path it returns on your include_directories() invocation. (You only need one of those, you call it twice right now.)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-02-09 04:51:45 -0500

Seen: 1,115 times

Last updated: Feb 09 '16