ROS/catkin compiled C++ file won’t find image sources

  allegro5, c++, catkin, ros

I created a C++ game that uses images from a folder in the same parent directory.


Program uses Allegro 5 library to include images:

ALLEGRO_BITMAP* icon1 = al_load_bitmap("Images/icon1.png");
ALLEGRO_BITMAP* icon2 = al_load_bitmap("Images/icon2.png");

And this works great.

However now I need to place this program into ROS/catkin package ‘beginner_tutorials’. If I place both Images folder and game.cpp into ../catkin_ws/src/beginner_tutorials it compiles fine using catkin make, but I get Segmentation Fault during runtime.


I used gdb and guess the error is caused by the program not finding the Images folder.

I also tried to place the Images folder to ../catkin_ws/devel/include/beginner_tutorials (the same place where header files are included)


and changed code accordingly:

ALLEGRO_BITMAP* icon1 = al_load_bitmap("beginner_tutorials/Images/icon1.png");
ALLEGRO_BITMAP* icon2 = al_load_bitmap("beginner_tutorials/Images/icon2.png");

But this didn’t work.
Where am I supposed to place the Image folder for it to be successfully included in the code? Do I also need to make adjustments in the CMakeLists.txt?

Source: Windows Questions C++