Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » No source file named main.cpp((compared with NetBeans))
No source file named main.cpp [message #792881] Tue, 07 February 2012 14:24 Go to next message
Denis Davydov is currently offline Denis DavydovFriend
Messages: 8
Registered: January 2012
Junior Member
Dear All,

Recently I experienced very common problem with
"No source file named /home/.../main.cpp."
With "Stop on startup at: main", gdb stops in main, but if I now try to add a breakpoinst there, I get this error.
If I have any breakpoints set up anywhere else (even in main.cpp) and I hit "Resume" - gdb does not stop there.
That's what I see in gdb traces:

193,524 23-break-insert --thread-group i1 -f /home/.../src/main.cpp:29
193,544 &"No source file named /home/.../src/main.cpp.\n"
193,545 23^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending=\
"/home/.../src/main.cpp:29",times="0",original-location="/home/.../src/main.cpp:29"}
193,545 (gdb) 


My project is made from existing sources and is compiled with "-g" option from a Makefile.

In "Debug Configurations->Source" I tried different configurations, as well as including just a FileSystem Dirrectory. Nothing helps.

The program runs from a folder other than one it is compiled in, if that matters.

In order to be sure that it does not depend on my Makefile or external libs compiled with/withot "-g", I installed NetBeans and compiled it with the same Makefile and run with a same command in the same folder. And it does indeed work there, no errors from dgb when I add breakpoints.

So I can conclude that it must have something to do with settings in Eclipse. Or maybe a bug?
Could you please advise where to look at and what to check?

Another thing is when I open a main.cpp from the "Project Explorer" it shows the file as "my_project/main.cpp", whereas if I debug it, I see "/home/.../main.cpp".

Thank you in advance for your help.

p/s/ Eclipse version is:
Version: Indigo Service Release 1
Build id: 20110916-0149

p/p/s/ I can access GDB logs from both NetBeans and Eclipse, but I have absolutely no experience with GDB...

[Updated on: Tue, 07 February 2012 14:39]

Report message to a moderator

Re: No source file named main.cpp [message #792900 is a reply to message #792881] Tue, 07 February 2012 14:50 Go to previous messageGo to next message
HagenFriend
Messages: 90
Registered: April 2010
Member
On 2/7/2012 3:24 PM, Denis Davydov wrote:
> The program runs from a folder other than one it is compiled in, if that
> matters.

It does matter.
Re: No source file named main.cpp [message #792977 is a reply to message #792900] Tue, 07 February 2012 16:23 Go to previous messageGo to next message
Denis Davydov is currently offline Denis DavydovFriend
Messages: 8
Registered: January 2012
Junior Member
Hagen wrote on Tue, 07 February 2012 09:50
On 2/7/2012 3:24 PM, Denis Davydov wrote:
> The program runs from a folder other than one it is compiled in, if that
> matters.

It does matter.


Well, that is the case for both NetBeans and Eclipse.
So, which settings do I need to check in order to make Eclipse work as expected?

[Updated on: Tue, 07 February 2012 16:23]

Report message to a moderator

Re: No source file named main.cpp [message #793478 is a reply to message #792977] Wed, 08 February 2012 07:23 Go to previous messageGo to next message
HagenFriend
Messages: 90
Registered: April 2010
Member
On 2/7/2012 5:23 PM, Denis Davydov wrote:
> So, which settings do I need to check in order to make Eclipse work as
> expected?

In order to find the correct sources, debugger and debug IDE (gdb? and
Eclipse) BOTH must have the same understanding about where they are.

The debugger gets the info from the binary file.
Eclipse gets the info from the local project settings.

As I see it, you will have either to compile from a path within an
Eclipse project, or convince Eclipse to work with a different path.

[With the information you supplied nobody can answer your question.
No offense, but personally, I'd recommend to read, understand, and
follow the advice Eric Steven Raymond gives in "How To Ask Questions The
Smart Way". You get answers much faster. And useful ones.]
Re: No source file named main.cpp [message #793501 is a reply to message #793478] Wed, 08 February 2012 08:08 Go to previous messageGo to next message
Denis Davydov is currently offline Denis DavydovFriend
Messages: 8
Registered: January 2012
Junior Member
Hagen wrote on Wed, 08 February 2012 02:23
On 2/7/2012 5:23 PM, Denis Davydov wrote:
> So, which settings do I need to check in order to make Eclipse work as
> expected?

In order to find the correct sources, debugger and debug IDE (gdb? and
Eclipse) BOTH must have the same understanding about where they are.

The debugger gets the info from the binary file.
Eclipse gets the info from the local project settings.

As I see it, you will have either to compile from a path within an
Eclipse project, or convince Eclipse to work with a different path.



Probably I did not make it clear before, but I compile from the path WITHIN the eclipse project. And I don't move binary file afterwards, I just specify Debug settings "Working directory" as something external. That's it.
So, judging from the Eclipse GUI that functionality should already be there.

[thank you for your advice. No offense, but the last time I asked a similar question with regards to another C++ IDE led to a bug filling and an update in the IDE. Actually another question of mine already led to a bug fix in PTP Eclipse, so it's not the first time I ask questions on-line...]

[Updated on: Wed, 08 February 2012 08:28]

Report message to a moderator

Re: No source file named main.cpp [message #793554 is a reply to message #793501] Wed, 08 February 2012 09:30 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Do you use the DSF debugger interface in Eclipse ?(see http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_choose_another_debugger_integration_for_CDT.3F )
I would advise to do so if not.
What are your settings in Debug Configuration->Source tab for the Source lookup path? I usually use here "Absolute File Path" only.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: No source file named main.cpp [message #793574 is a reply to message #793554] Wed, 08 February 2012 09:56 Go to previous messageGo to next message
Denis Davydov is currently offline Denis DavydovFriend
Messages: 8
Registered: January 2012
Junior Member
Axel Mueller wrote on Wed, 08 February 2012 04:30
Do you use the DSF debugger interface in Eclipse ?(see http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_choose_another_debugger_integration_for_CDT.3F )
I would advise to do so if not.
What are your settings in Debug Configuration->Source tab for the Source lookup path? I usually use here "Absolute File Path" only.


Thank you for your advices.
Yes, I do have DSF interface used ("Using GDB(DSF) Create Process Launcher").
In Configuration->Source tab I had several options: a) Default b) path to the src's (only). If I use only "Absolute File Path" I have another error:

Can't find a source file at "main.cpp" 
Locate the file or edit the source lookup path to include its location.

If I do "Locate File" and point to "main.cpp" the screen flickers but nothing changes, nothing in logs.
I don't see any errors in GDB traces.

Re: No source file named main.cpp [message #793681 is a reply to message #793574] Wed, 08 February 2012 12:34 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Hm, that is weird. OK, then try to add "Compilation directory".

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: No source file named main.cpp [message #793704 is a reply to message #793681] Wed, 08 February 2012 13:04 Go to previous messageGo to next message
Denis Davydov is currently offline Denis DavydovFriend
Messages: 8
Registered: January 2012
Junior Member
Axel Mueller wrote on Wed, 08 February 2012 07:34
Hm, that is weird. OK, then try to add "Compilation directory".


Thank you for your help, it works now.
Somehow Default inclusion of project folder with its sub-folders didn't work.
Sub-folders have some duplicated files which are not used in compilation, but it is definitely not the reason since I tried adding "Compilation directory" with sub-folders and it also works with no problems.

[Updated on: Wed, 08 February 2012 13:04]

Report message to a moderator

Re: No source file named main.cpp [message #1057869 is a reply to message #792881] Thu, 09 May 2013 12:51 Go to previous message
Jan Sebesta is currently offline Jan SebestaFriend
Messages: 1
Registered: May 2013
Junior Member
Another hint, why you can get message "No source file named yourname.c.".

Imagine, the project consists of many source files and only some of them are linked together into resulting executable file.

If your yourname.c is not the one, that is linked to the resulting executable, then when you start a debugging and put a breakpoint into such file, it will result in the message "No source file named yourname.c.".
Previous Topic:set solib-search-path" or "set sysroot error
Next Topic:Retrieving Problem Messages from C Compiler
Goto Forum:
  


Current Time: Sun Dec 21 04:15:16 GMT 2014

Powered by FUDForum. Page generated in 0.01884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software