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

Not able to run image_transport from cpp code: ` Segmentation fault (core dumped)`

asked 2016-07-17 22:43:26 -0500

polar gravatar image

updated 2016-07-18 06:49:42 -0500

I included well image_transport in both my CMake file and packake.xml as follows:

find_package(catkin REQUIRED COMPONENTS


  CATKIN_DEPENDS  cv_bridge image_transport roscpp rospy std_msgs message_generation




and in my .cpp file

#include <ros/ros.h>
#include <image_transport/image_transport.h>
int main(int argc, char **argv)

  ros::init(argc, argv, "imagegraber");
  ros::NodeHandle nodea;

 image_transport::ImageTransport it(nodea);

image_transport::Subscriber sub = it.subscribe("/pg_15508342/image_raw", 1, imageCallback);

return 0;

Yet, I receive Segmentation fault (core dumped) when I run my code.... What could be the problem? The code crashes at image_transport::ImageTransport it(nodea);

Am also able to run image_transport with command line: rosrun image_transport republish..... Able also to use image_view, etc...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-18 22:55:25 -0500

polar gravatar image

I think I can see now the origin of the problem. It is related to Boost included from outside ros. In fact I should have reported my full CMakeLists.txt in the question, but I was initially far from thinking the issue was in any how related...

In my CMakeLists.txt I included my own boost (latest version downloaded from source) like

SET (BOOST_DIR "/home/polar/soft/lib/boost/boost_1_61_0")
SET (BOOST_INCLUDEDIR "/home/polar/soft/lib/boost/boost_1_61_0/build/include")
SET (BOOST_LIBRARYDIR "/home/polar/soft/lib/boost/boost_1_61_0/build/lib")

FIND_PACKAGE(Boost 1.61.0 REQUIRED thread)
if (NOT Boost_FOUND)
  message(FATAL_ERROR " Fatal error: Boost (version >= 1.55) required.")
  message(STATUS "Setting up BOOST")
  message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
  message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
endif (NOT Boost_FOUND)

As such I got segmentation fault at image_transport::ImageTransport it(nh);. However, after replacing the above CMake code with only


I no longer have that segmentation fault.

Thus another question, how to use the standalone Boost with ROS catkin??

edit flag offensive delete link more



Your 'stand-alone Boost' question should really be a new question (but please use the search first, as it has been asked many times already), but in short: you can't. Or at least, not without building all of ROS from source using your version of Boost.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-19 03:20:30 -0500 )edit

@gvdhoorn please what has already been answered: the ability to use a standalone boost with ros or the fact that the segmentation fault is due to the standalone boost?

polar gravatar image polar  ( 2016-07-19 04:20:23 -0500 )edit

Both questions have been answered previously, actually.

But again: to use a different version of Boost than the one that is used to build the binary ROS packages, you'll need to build all packages you use from source, making sure the build scripts finds and uses your Boost version.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-19 05:04:37 -0500 )edit

I would be grateful if you can provide me the link. I found only quite few answers related to segmentation fault with image_transport....

polar gravatar image polar  ( 2016-07-19 20:40:46 -0500 )edit

Be aware of potential compatibility problems though. There is no guarantee that all packages will be compatible with newer Boost versions, as they haven't been tested with them.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-20 06:27:15 -0500 )edit

@gvdhoorn Thanks for the info. But still, NONE of these report the issue related to image_transport (segmentation fault).

polar gravatar image polar  ( 2016-07-20 21:18:52 -0500 )edit

I had understood that you wanted info about incompatibility between binary ROS distributions and from-source built pkgs with a different version of Boost.

And the issue is universal, it's not limited to image_transport, or even ROS: mixing different Boost versions can always lead to problems.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-21 01:15:03 -0500 )edit

Question Tools

1 follower


Asked: 2016-07-17 22:43:26 -0500

Seen: 420 times

Last updated: Jul 18 '16