News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

First steps to using C::B with Cygwin

Started by johne53, August 18, 2008, 12:43:34 PM

Previous topic - Next topic

johne53

I installed Cygwin yesterday (under WinXP). I've copied a simple GTK+ 'Hello World' type app from a book and I'm trying to build it in C::B. In the project options I set the compiler type to Cygwin GCC. But I haven't done anything else (such as telling it which folder the compiler can be found in). I installed Cygwin in its recommended folder of C:\Cygwin.

Whenever I try to compile my source file I see this error message:-

QuoteExecution of 'gcc.exe -Wall  -g  -IC:/Cygwin/include -IF:/GTK/HelloWorld -c F:/GTK/HelloWorld/HelloWorld.c -o obj/Debug/HelloWorld.o' in 'F:\GTK\HelloWorld' failed.

My guess is that gcc.exe isn't being found - and if it's not a dumb question, why should it be?? Cygwin is supposedly a POSIX emulation layer for Windows so it knows nothing at all about exe files.

Do I need to install something else in order to get gcc.exe - or is C::B looking for the wrong thing?

johne53

My apologies.... I hadn't installed *enough* of Cygwin to get the gcc package - and it does indeed come as an exe. I still need to set up some default search folders etc but it now looks as if it will work.  :oops:

johne53

Oh dear - it looks like setting the compiler directories isn't as simple as I thought. Let's take the GTK headers as an example. Many source files contain lines like this:-

#include <gtk/gtk.h>

Note the use of angle brackets to indicate that the folder & file are relative to the compiler's location. The full path to gtk.h is actually C:/cygwin/usr/include/gtk-2.0/gtk/. So the compiler (gcc.exe) would need to be in C:/cygwin/usr/include/gtk-2.0/ for this to work. Unfortunately, gcc.exe is actually located in C:/cygwin/bin/ so the required file can't be found. Is there a way to correct this without needing to specify the full path of every standard header? I guess I need to set something up so that C:/cygwin/usr/include/gtk-2.0/ gets used as the starting point. Hope that makes sense.

dmoore

you can try using global variables (settings -> global variables) and define a "gtk" variable with relevant paths to includes, libs etc. Then include $(#gtk.include) as the search dir for includes, $(#gtk.lib) as the search dir for libs etc

alternatively, codeblocks understands backticks allowing you to use something like `pkg-config <PACKAGENAME> --cflags` in your projects compiler settings (other options) and `pkg-config <PACKAGENAME> --libs` in linker settings (assuming cygwin has pkg-config)
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

johne53

Thanks for the tips but I think I found the problem. Although I set the compiler (for this project) to be Cygwin-GCC I hadn't saved it as the default compiler. Next time I opened the project it was set to a different compiler and I hadn't noticed. So unqittingly, I was adding all my path options to the wrong compiler !