“No source available for main()” error when debugging simple C++ in Eclipse with gdb

后端 未结 13 1361
醉梦人生
醉梦人生 2020-12-29 04:51

I\'m having trouble debugging a C++ program in Eclipse (the latest RC of Helios, updated with latest CDT from within itself) on OSX.

The program is very simple (esen

相关标签:
13条回答
  • 2020-12-29 05:20

    Encountered the same problem once. You just have to go to your Project Properties, by hitting ALT+ENTR or right click project and scroll down at the bottom and you will find Properties. Expand C/C++ build on the left. Then click on settings. Once you open the settings, then click on tool settings. In the MCU GCC Compiler, there is a debugging option. Click on debugging and add

    -g -O0
    

    in the Other debugging flags. Trying debugging the project now.

    0 讨论(0)
  • 2020-12-29 05:23

    Here is another reason for this problem. My configuration used -g3 as the option to gcc. Changing it to -g solved the problem. There seems to be some incompatibility between gcc and gdb. I checked that gdb was the latest revision (using apt-get).

    0 讨论(0)
  • 2020-12-29 05:29

    For anyone else who may experience this issue,

    I installed the linuxtools/valgrind plugin last night to do some memory profiling, and it seems that this broke the normal gdb. when i removed the linuxtools plugins everything started working as normal again.

    So you might like to try that.

    0 讨论(0)
  • 2020-12-29 05:30

    Go to project Properties, C/C++ Build -> Settings. On the first tab (Tool Settings) under Cross GCC Compiler click Debugging and set Debug Level to Maximum (-g3)

    0 讨论(0)
  • 2020-12-29 05:30

    This issue depends on how gdb is being invoked. I found I needed to manually specify the source file locations when I got that error. Even though I'd already configured that under project properties. After doing so, Eclipse no longer had a problem supplying the appropriate source.

    Using the release versus debug version of a library may be your specific problem (if you were building a library from source then debugging it). If someone is using a precompiled library, they'd never be able to set breakpoints within it and so that fix wouldn't apply to them.

    0 讨论(0)
  • 2020-12-29 05:33

    I would like to add a little new blood to this old thread.

    I encountered this problem when I tried to compile and debug a gnu arm project.

    I solved the problem by modifying the Makefile: adding "-g -O0" at the end of this line "CFLAGS += -Wall -Werror -O3"

    0 讨论(0)
提交回复
热议问题