Page 1 of 1

using Cygwin with CodeLite

Posted: Mon Jan 14, 2013 6:39 am
by zashaw
Hi, is there a way of using CodeLite with Cygwin instead of MinGW on Windows? I need to use a library that builds easily under Cygwin, but has problems with mmap functions under MinGW, and seems like it'd be a pain to get it to work. Some of the options under "Settings/Debugger settings", mention Cygwin, so I thought that it might work (despite Google not returning anything definitive), but I can't get debugging to work.

I also wonder if there are any disadvantages to using Cygwin, other than installing Cygwin.

Here's some details on what I've tried, and the problems I've had:

I was able to build by adjusting under menu 'Settings/Build settings'. Under 'Build systems', I put the Cygwin make.exe instead of the MinGW version. Under the 'Compilers' tab, I un-checked 'Use compiler MT' and 'Pass object list .. via file', since there were DOS-format file names that confused Cygwin's make.

However, I couldn't figure out how to get debugging to work. Under menu Settings/Debugger Settings, I set the 'Debugger path' to Cygwin's gdb, and I tried setting 'Cygwin path conversion command' to c:/cygwin/bin/cygpath.exe -w $(File). I used Create new project to create the default project with the "Simple executable (gcc)" template, stuck a breakpoint on the line 'printf("Hello workld\n");', and ran under the debugger (F5 key) . The program starts running, but the breakpoint is never entered, and the program hangs. If I select 'Debug/Pause debugger', it says "Can't interrupt debuggee process: I don't know it's PID!". However, if I select 'Debug/Stop debugger', it kills the program and exits debug mode, as expected.

Also, if I select 'Build/Run', the program runs as expected. And if I use CodeLite's default settings (i.e., using MinGW), it runs under the debugger as expected. So the problem seems to just be with integrating Cygwin's gdb.

I'm using CodeLite 4.1.5770 on Windows 7.

Thanks!

-Z.

P.S.: in my tests so far, CodeLite seems to implement pretty much every feature from Visual Studio that I use. Thanks to the developers!

Re: using Cygwin with CodeLite

Posted: Mon Jan 14, 2013 11:43 am
by eranif
zashaw wrote:I also wonder if there are any disadvantages to using Cygwin, other than installing Cygwin.
Its matter of taste, I personally don't like cygwin as it comes with a bloated installation
zashaw wrote:I un-checked 'Use compiler MT' and 'Pass object list .. via file', since there were DOS-format file names that confused Cygwin's make.
This was fixed last week or so, it now uses a relative path which is always the file name only without the path (i.e. no more backslashes)
zashaw wrote:However, I couldn't figure out how to get debugging to work. Under menu Settings/Debugger Settings, I set the 'Debugger path' to Cygwin's gdb, and I tried setting 'Cygwin path conversion command' to c:/cygwin/bin/cygpath.exe -w $(File). I used Create new project to create the default project with the "Simple executable (gcc)" template, stuck a breakpoint on the line 'printf("Hello workld\n");',
Probably because cygwin's gdb reported paths that codelite could not understand... (e.g. /c/cygwin/...)

Posting the debugger output as advised on the forum sticky post could have helped here
zashaw wrote:The program starts running, but the breakpoint is never entered, and the program hangs. If I select 'Debug/Pause debugger', it says "Can't interrupt debuggee process: I don't know it's PID!". However, if I select 'Debug/Stop debugger', it kills the program and exits debug mode, as expected
Its different processes. there are 3 processes involved:
codelite -> gdb -> debuggee

To be able to place breakpoints, codelite needs to send SIGINT to the debuggee (NOT to gdb) to gain control.
Since codelite did not manage the resolve the debuggee PID, it was not able to do it - again this is related to the path resolving issue

PS: I tried installing cygwin to give it a try, however http://www.cygwin.com seems to be down...

Eran

Re: using Cygwin with CodeLite

Posted: Wed Jan 16, 2013 6:56 am
by zashaw
As it turns out, my problem had to do with my old version of Cygwin. When I install the latest version (1.7.15), my problem goes away. I noticed in the debugger output that the old Cygwin was using gdb 6.8, so perhaps that's the issue. (It's what made me thing of updating Cygwin.)

On the off-chance it's helpful, I've attached debugger log files with old Cygwin, new Cygwin and MinGW.

Also, for others, it'd be nice to have instructions on how to use CodeLite with Cygwin somewhere (e.g. http://codelite.org/LiteEditor/Documentation). The following seems to work for me, although there might be glitches I haven't run into yet:

---begin Cygwin instructions

Assume that Cygwin is installed in C:\cygwin

From the menu, select 'Settings / Build Settings'. Under the 'Compilers' tab, select 'Tools' on the left pane for the relevant system. Under 'PATH environment variable' enter c:/cygwin/usr/local/bin;c:/cygwin/bin (this will override MinGW tools, which would otherwise be in the PATH).

For older versions of CodeLite, click on 'Advanced' in the left pane, and un-check 'Use compiler -MT...' and 'Pass object list...'. If, when you build an application, you see an error like Debug/main.o.d:1: *** target pattern contains no `%'. Stop., you'll need to un-check these options, then select 'Build / Rebuild workspace' from the menu.

Select the 'Build Systems' tab. Under 'Build Tool', enter c:/cygwin/bin/make.exe and Click 'Ok'.

From the menu, select 'Settings/ Debugger Settings'. Make sure 'General' is selected on the left pane. Under 'Debugger path', enter c:/cygwin/bin/gdb.exe

Select 'Misc' on the left pane. Under 'Cygwin path conversion command', enter c:/cygwin/bin/cygpath.exe -w $(File)

----end Cygwin instructions

Re: using Cygwin with CodeLite

Posted: Wed Jan 16, 2013 7:59 pm
by zashaw
now that I'm trying things out more, I see one additional setting to get Cygwin working:

From the menu, select 'Settings / Environment Variables', and add (in the big text box): PATH=c:\cygwin\usr\local\bin;c:\cygwin\bin
(Otherwise, your process will load MinGW's version of cygwin1.dll, instead of Cygwin's version of this file.)

Re: using Cygwin with CodeLite

Posted: Wed Jan 16, 2013 9:53 pm
by eranif
zashaw wrote:As it turns out, my problem had to do with my old version of Cygwin. When I install the latest version (1.7.15), my problem goes away. I noticed in the debugger output that the old Cygwin was using gdb 6.8, so perhaps that's the issue. (It's what made me thing of updating Cygwin.)

On the off-chance it's helpful, I've attached debugger log files with old Cygwin, new Cygwin and MinGW.

Also, for others, it'd be nice to have instructions on how to use CodeLite with Cygwin somewhere (e.g. http://codelite.org/LiteEditor/Documentation). The following seems to work for me, although there might be glitches I haven't run into yet:

---begin Cygwin instructions

Assume that Cygwin is installed in C:\cygwin

From the menu, select 'Settings / Build Settings'. Under the 'Compilers' tab, select 'Tools' on the left pane for the relevant system. Under 'PATH environment variable' enter c:/cygwin/usr/local/bin;c:/cygwin/bin (this will override MinGW tools, which would otherwise be in the PATH).

For older versions of CodeLite, click on 'Advanced' in the left pane, and un-check 'Use compiler -MT...' and 'Pass object list...'. If, when you build an application, you see an error like Debug/main.o.d:1: *** target pattern contains no `%'. Stop., you'll need to un-check these options, then select 'Build / Rebuild workspace' from the menu.

Select the 'Build Systems' tab. Under 'Build Tool', enter c:/cygwin/bin/make.exe and Click 'Ok'.

From the menu, select 'Settings/ Debugger Settings'. Make sure 'General' is selected on the left pane. Under 'Debugger path', enter c:/cygwin/bin/gdb.exe

Select 'Misc' on the left pane. Under 'Cygwin path conversion command', enter c:/cygwin/bin/cygpath.exe -w $(File)

----end Cygwin instructions
I am refactoring a bit the build settings atm (moving the 'make' to become part of the toolchain) this will allow to use different make commands for various compilers.
The end result will include an out of the box compiler definition for cygwin which will require minimum by the end user, if any

Eran

Re: using Cygwin with CodeLite

Posted: Thu Jan 17, 2013 2:58 am
by eranif
In the trunk, you can now define new compiler and set the toolchain to use cygwin toolchain. This is now doable because the 'Make' is now also
part of toolchain (while before it was defined separately)

Attached is a screenshot of how I defined cygwin on my machine
1.png
Eran

Re: using Cygwin with CodeLite

Posted: Thu Jan 17, 2013 8:50 am
by zashaw
This seems a great idea, and should make the Cygwin instructions unnecessary . Thanks!

One thing: it seems like like I still have to override the PATH in Settings/Environment Variables (or MinGW is in the path, and I get the wrong cygwin1.dll), and the debugger path in Settings/Debugger Settings (otherwise I'm running MinGW's gdb). I think those variables might have to be defined as a property of the compiler in your revamped Build Settings window.