User forums > Using Code::Blocks

cannot locate error line, if compilation error occured

<< < (2/2)

alys666:

--- Quote from: stahta01 on January 23, 2017, 05:57:25 pm ---Is the makefile in the same folder as the cbp file?
Does the makefile call other makefiles or use the cd command?
Edit: Is the CB Project set to use the correct compiler?
Edit2: Is the correct compiler set as the default compiler?
Tim S.

--- End quote ---
1. folders of cbp and make files(there are few makefiles and moreover sh scripts to build application) are different, because of simple reason. I develop my code in a team, but people aren't using CB, when I like CB. so to prevent mixing of sources and specific for me project files, i use separate folder for .cbp.
Imo, restriction that cbp and makefiles must be in the same folder is too hard.

2. in reality my custom make command calls sh script, which calls couple of makes, and one of them calls makefiles from folders tree. so structure of makefiles quite complex.

3. default compiler is gcc, which i use. error/warnings decoding is correct. error parser is able to get source file path and error line.

4. there is your good idea, that current dir is changing during such complex invocation of makefiles, and CB cannot properly locate it.

alys666:
i've found the reason:  at least i'm closer to solution...

gcc compiler gives error/warning in form(build log):
tasks.cpp:292:36: warning:........

but CB decodes it as(Build Messages):
../../firmware/tasks.cpp|292|warning: ......

and here is error, because in reality the relative(to .cbp file) path is:
../../firmware/LIB/tasks.cpp

and in .cbp this file is recorded as:
   <Unit filename="../../firmware/LIB/tasks.cpp" />


so it missed subfolder LIB, but properly found that it is ../../firmware folder.

hmm...

Jenna:
I compile my wxWidgets from git with a custom-makefile project, where the Makefile is in a build-folder, the sources are in a source folder and the projectfile is in a third-folder and jump to errors works fine.

Did you set the execution-directory on the first tab ("Project settings") of the project properties dialog to the folder, where the makefile is located ?

alys666:

--- Quote from: jens on January 23, 2017, 09:21:13 pm ---I compile my wxWidgets from git with a custom-makefile project, where the Makefile is in a build-folder, the sources are in a source folder and the projectfile is in a third-folder and jump to errors works fine.

Did you set the execution-directory on the first tab ("Project settings") of the project properties dialog to the folder, where the makefile is located ?

--- End quote ---

I solved the problem and understood the reason.
problem that CB just takes this "execution directory" and adds it to the file path(name) given by compiler in error/warning. and it can bring errors.
it can be solved easy. you must give sources in full paths to gcc. then gcc will return full path in error/warning, and CB will correctly find file and line.

Your advice will work only if you have one makefile in "execution directory". And you give to gcc all your sources relatively to this directory. Then path = execution directory +"/" + path_from_gcc_message will point correctly to the file.

But my "give source in absolute path" advice seem is universal.

So finally:
if you have custom make file or some custom build system, to preserve an ability to locate error/warning file and line, given by gcc(or supported compiler), you must:
1. or have absolute paths in compiler error/warning message
2. or have relative to "execution directory"(first tab of project settings) paths.

Navigation

[0] Message Index

[*] Previous page

Go to full version