I am trying to set up Eclipse IDE 2020-06 on MacOS Catalina (10.15.6) such that it works with CImg. I am running the standard program as provided on the CImg:
using namespace cimg_library;
int main() {
CImg<unsigned char> image("lena.jpg"), visu(500,400,1,3,0);
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.blur(2.5);
CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");
while (!main_disp.is_closed() && !draw_disp.is_closed()) {
main_disp.wait();
if (main_disp.button() && main_disp.mouse_y()>=0) {
const int y = main_disp.mouse_y();
visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.width()-1,y,0,0),red,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,1,image.width()-1,y,0,1),green,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,2,image.width()-1,y,0,2),blue,1,1,0,255,0).display(draw_disp);
}
}
return 0;
}
This works perfectly fine when compiling and running it from the terminal using:
>> g++ -o load_image.o -L /opt/X11/lib -I /opt/X11/include load_image.cpp -lX11 -lpthread
>> ./load_image.o
When I try to do this from Eclipse the compilation works fine, but when trying to run the code I get the error:
[CImg] *** CImgIOException *** [instance(0,0,0,0,0x0,non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file 'lena.jpg'.
libc++abi.dylib: terminating with uncaught exception of type cimg_library::CImgIOException: [instance(0,0,0,0,0x0,non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file 'lena.jpg'.
The includes and libraries set up in eclipse are as below:
Does anybody know what is wrong with my settings in Eclipse?
Edit:
As suggested, the used debugger settings are as shown below:
Update When running the terminal-compiled program with gdb I get no problems. I can not test if the eclipse-compiled program runs in terminal due to those files being locked somehow.