如果你认为本系列文章对你有所帮助,请大家有钱的捧个钱场,点击此处赞助,赞助额0.1元起步,多少随意
声明:本文只用于个人学习交流,若不慎造成侵权,请及时联系我,立即予以改正
锋影
email:174176320@qq.com
这个现象是由于编译器进行了代码优化导致:
1、找到项目属性设置,编译器选项设置,添加 -g -O0 选择项:
2、如果还是无法进入源码调试,将编译器优化选项手动禁止:
3、如果无法进入静态库进行源码调试,请将静态库项目的属性按照上面的要求同样设置。
原文:
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:
> 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