I have a project that has more makefiles. At some specific folders, there are some makefiles that can create binaries/executables. I right-click on the makefile and do a Make Tarkgets -> Build -> all
, so I get the executable right there. If I run the executable from console, it works fine, but if I do a right-click on it and Debug as -> Local C/C++ Application
, it runs but at some point it is reading a file with relative path:
FILE *f = fopen(fName, "rb"); // fname is a relative path : ../../../path/to/file
if(f == NULL)
{
perror(fName);
exit(2);
}
and it is not finding it; the pointer is empty/NULL. To me it seems like Eclipse is searching for the file from the place where the project was opened, not from where the executable is. I suppose this because if I create a project from the makefile that created the executable, it works, it finds the file. But from that place I cannot see the sources, so, for placing breakpoints I have to run step-in by step-in until I get in the right place/right source.
Can anyone help me to fix this thing? Is there a way to make it search the file from the place where the executable is? Thanks
P.S. : I've seen this post, it's similar, but it did not pointed me to anything...