Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: pozzugno on March 10, 2021, 01:51:47 pm

Title: Custom Makefile: double click on compiler errors doesn't open the source file
Post by: pozzugno on March 10, 2021, 01:51:47 pm
I have a project with the following structure:

prj
  prj.cbp
  src
    main.c
    ...
  build
    mingw
      Makefile


In the Project->Properties I set build\mingw as the Execution directory. In the Build options I set $make -f $makefile as command for Build project/target.
The compilation works well.

If there's a compilation error, the compiler outputs something similar (in Build log):

../../src/main.c: In function 'app_init':
../../src/main.c:459:31: error: expected ';' before numeric constant
    app_trigger_signal_on_GPIO 7);
                               ^
mingw32-make.exe: *** [Makefile:1120: output/objs/qcli/pal.o] Error 1


In the Build messages window I see the row:

build\mingw\src\main.c|459|error: expected ';' before numeric constant|

Of course, when I double click on this row, C::B doesn't open the relevant file, because it is src/main.c (relative to project file) and not build\mingw\src\main.c.

What is the solution of this problem?

I tried to set Execution directory to . (the same folder of project file), but at the moment make works only if launched in the same directory of Makefile (build/mingw).
Title: Re: Custom Makefile: double click on compiler errors doesn't open the source file
Post by: oBFusCATed on March 10, 2021, 02:25:57 pm
I'm not sure these is a solution to this problem. Does it work if you use "make -f build/mingw/Makefile" as the build command?
Title: Re: Custom Makefile: double click on compiler errors doesn't open the source file
Post by: pozzugno on March 10, 2021, 03:08:03 pm
I'm not sure these is a solution to this problem. Does it work if you use "make -f build/mingw/Makefile" as the build command?

Do you mean changin execution directory too in Project -> Properties? Yes, it works, but I have to fix something in the Makefile.

Anyway, why C::B transform the file ../../src/main.c in the compiler error message into build\mingw\src\main.c? It doesn't make sense to me.
Title: Re: Custom Makefile: double click on compiler errors doesn't open the source file
Post by: oBFusCATed on March 10, 2021, 08:56:37 pm
Because someone has to implement a translation and every target can have a different execution path, so it becomes complicated, probably.