這個現象是因爲編譯器進行了代碼優化致使:html
一、找到項目屬性設置,編譯器選項設置,添加 -g -O0 選擇項:node
二、若是仍是沒法進入源碼調試,將編譯器優化選項手動禁止:windows
三、若是沒法進入靜態庫進行源碼調試,請將靜態庫項目的屬性按照上面的要求一樣設置。dom
原文:eclipse
http://eclipse.1072660.n5.nabble.com/No-source-available-for-quot-main-quot-td59554.html優化
Thanks! Following your suggestion, I solved both problems. It works
like a charm!
Best,
Michael Chen
On Wed, Nov 12, 2008 at 3:13 AM, Subs <[hidden email]> wrote:ui
> 1. Unable to debug: You probably haven't built for debug. Use the -g -O0
> options to the compiler for debug build
> 2. Highlight moving randomly: This is probably becuase you have built for
> debug, but with a high level of optimisation. When optimised, the compiler
> will move code around to make it optimal, but this pretty much break the
> association with the source - hence what you are seeing.
>
> Michael Chen wrote:
>>
>> hey, there,
>>
>> I imported an existing C project with working Makefiles. And in the
>> project property, I ticked off "Use default build" and "Generate
>> Makefile Automatically", and I supplied the Bulding command
>> "/usr/bin/make". The project build smoothly and run without problem.
>> And in the editor windows, CTRL+click on variable names, types or
>> macros, leads me to all right places.
>>
>> However I can not debug it. The error is No source available for
>> "main() " . I setup the Source in the Run/Debug Dialog in all
>> possible ways I can imagine, and get the same error. There is another
>> executable generated in a deep subdirectory, and I can at least see
>> the debug window for it, click on Step Over, however, I see the
>> highlights jumps around in its source file randomly. It seems that I
>> missed something. Please help me out, thanks!
>>
>>
>> Best Regards,
>> Michael Chen
this