13

I installed cygwin (the latest 1.7.xx?), and then installed eclipse cdt (Juno).

When I tried to build a hello world project, despite eclipse identifying that cygwin was installed, it didn't work.

So I manually added c:\cygwin\bin to the path, which found all the executables in cygwin, including g++, make ld, etc.

Now, eclipse can build the project, but when debugging, gdb starts up and can't find the source code. It claims that it can't find:

/cygdrive/c/users/me/workspace/test1/test1.cc . even though that's exactly where it is. It's as though cygwin's directory system doesn't work.

I can manually load the source from:

c:\users\me\workspace\test1\test1.cc

and the debugger works, but the next time I start a new project, I have to do it again. How do you instruct the eclipse/cygwin combo to correctly find source code?

Alternatively, is Mingw any easier? I have experienced similar problems with eclipse seeing that mingw is there, but build failing because it doesn't find the executable.

Dov
  • 8,000
  • 8
  • 46
  • 75
  • You may want to rephrase the question to show the real question you want to ask. – Alvin Wong Jun 24 '13 at 06:34
  • 1
    This is ridiculous. The question is how to get eclipse to properly match wtih cygwin so that they debugger works without manually having to manually tell it where each source file is every time. That seems pretty obvious to me from reading my question. If Mingw is an option, how does it work, because I've had similar problems. – Dov Jun 24 '13 at 10:05

6 Answers6

16

Here is how I made it work.

  1. I goto Window ==> Preferences ==> C/C++ ==> Debug ==> Source Lookup Path
  2. I Add a Path Mapping: Project Source
  3. On the left side I put the path that Cygwin expects, i.e. \home\MyName\projects and on the right side I put the Windows path, i.e. C:\cygwin\home\MyName\projects

Then when I debug it finds the source file fine.

ParthaM
  • 176
  • 1
  • 3
  • Is there a way that this setting is shared with others via .project files? – Danijel Apr 27 '17 at 07:29
  • @Danijel, yes. Considering that all your projects reside in your Eclipse workspace folder, simply map Cygwin's Eclipse workspace path to your Windows Eclipse workspace path. All projects within that path will resolve source files correctly. – speed488 Oct 23 '19 at 12:03
13

Go to Windows->Preference->C/C++ -> Debug -> Source Lookup Path. Add following 'Path mapping'.

\cygdrive\c -> c:\
user3517051
  • 131
  • 1
  • 2
3

Although Above are given good answers but still it might not solve the problem sometimes phew!!!!

Suppose you install Cygwin in C: but your eclipse workspace is in D: then there is a problem in your mounting

all you should do is, open the cygwing shell & type "mount" to get the following :

  Ritvika@Ashutosh ~
  $ ls

  Ritvika@Ashutosh ~
  $ mount
  C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
  C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
  C:/cygwin64 on / type ntfs (binary,auto)
  C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
  D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)

  Ritvika@Ashutosh ~
  $

here my Projects are all under D:\ECWorkSpace, so my mapping needs to be present in Eclipse as: /cygdrive/d d:/

Hence, now Armed with this knowledge do what PathM says

 1. goto Window ==> Preferences ==> C/C++ ==> Debug ==> Source Lookup Path
 2. Add a Path Mapping: Project Source
 3. On the left side put "cygdrive\d",  & on the right put : "D:\"

This should work. ( It did for me :) ) You can Check this FAQ as well : https://wiki.eclipse.org/CDT/User/FAQ#I.27m_using_cygwin_and_when_launching_the_debugger.2C_it_complains_that_it_can.27t_find_the_source_file

AnotherDeveloper
  • 2,161
  • 2
  • 23
  • 27
2

I use MinGW + CDT, and it is giving me great satisfaction. I installed it many times and never had any disagreement. No much to configure than what you did with cygwin. Download the Eclipse for C/C++ developers (probably what you did) to get CDT (MinGW Tool Chain -> gdb + gcc) directly operational. Set your \\MinGW\bin\ directory into your PATH and you should be good to go...

Note : Like Cygwin, MinGW provides a Linux-like Shell.

For MinGW-64, ready-made builds are a little bit more difficult to locate. See here.

Community
  • 1
  • 1
Gauthier Boaglio
  • 10,054
  • 5
  • 48
  • 85
  • 1
    Still would like to know how to fix the cygwin problem, but for now the installer for mingw made this work. – Dov Jun 24 '13 at 11:18
  • Forgot to tell you that, for full 64 bit options (`-m64`, ...), you will need `MinGW-64`. See the link at the bottom of my answer. – Gauthier Boaglio Jun 24 '13 at 14:08
0

Look at set-up of "Common Source Lookup Path" here: http://wyding.blogspot.dk/2009/04/setup-cygwin-toolchain-in-eclipse-cdt.html

0

I replaced gdb with msys gdb. For example:

Current configuration:

... Application Configuration .. Debug .. Debug

GDB Debugger gdb

to

GDB Debugger path to msys gdb (like for example c:\msys\bin\gdb.exe
Elikill58
  • 4,050
  • 24
  • 23
  • 45
manu
  • 1