The source file cannot be located when debugging the makefile when compiling the debug version: No source available for “main() at 0x8544”

question

I used a makefile to compile a release version of the executable file before, but when I wanted to debug it later, I found that it couldn't be debugged.
I thought -git would solve the problem, but later I found out that it didn't work at all.

Although options have been added here -g, the source file still cannot be found during debugging.
Insert image description here
Insert image description here

solution

How to convert the release version of an existing C/C++ project compiled with a makefile into a debug version without changing the source code.
After carefully studying the makefile on this issue, I realized that the rules of the makefile are based on the timestamp.

In other words, if the source code does not change, .othe intermediate files generated by the original release version can be debugged even if options are added to the makefile later -g, but they cannot be entered into the source code. Because the source file has not changed, .othe intermediate file will not be regenerated, and the corresponding -goptions will not be added.

Final operation:

On the one hand: add compilation options in the makefile; -g
on the other hand:.oIt is very important to delete all intermediate files generated by the originally compiled release version .
There is also something mentioned in the book before: -goptions and code optimization options -O/O1/O2/O3should not appear at the same time.

Guess you like

Origin blog.csdn.net/Edwinwzy/article/details/130968590