User forums > Help

Error compiling under Cygwin

(1/2) > >>

JSeb:
Hi gurus, wizards and newbies.

I a new Code::Blocks convert, after flirting a bit with wxDev-CPP, and being dissapointed.

I tried to configure CB for CYGWIN by following the instruction here:
http://wiki.codeblocks.org/index.php?title=Installing_Cygwin_Compiler

I then tried to compile the ubiquitous "Hello World" code, and obtained an avalanche of errors ("was not decalred in this scope"... I don't think the exact errors are relevant in this post).

Looking at the Build Log, the first line reads:
g++.exe -mno-cygwin -IC:/Cygwin/usr/include -c "C:/Documents and Settings/JSeb/Mes documents/WorkSpace/FooBar2/main.cpp" -o obj/Debug/main.o


I then went to my cygwin console, and tried to compile with
g++.exe -mno-cygwin -c main.cpp -o main

Surprise surprise, it worked.

So in CB, Settings->Compiler and Debugger->Global Compiler Settings, tab Search directories->Compiler, I just erased the path C:\Cygwin\usr\include. Now the first line of the Buil Log reads:
g++.exe -mno-cygwin -c "C:/Documents and Settings/JSeb/Mes documents/WorkSpace/FooBar2/main.cpp" -o obj/Debug/main.o

And the compilation is successful.

So, what is happening here? Did I set up CB correctly to be used with Cygwin? How come explicitly specifying the search directory in the first case fails? Will I have any trouble?

Thank you kindly for your help!

thomas:
I'm not sure, but a rough guess about what the problem might be is this:
1. -mno-cygwin tell the compiler to build a "no cygwin" program (duh).
2. you specify a header search path that contains cygwin standard headers which don't contain something (some CRT funcs)
3. the compiler uses the headers found there and doesn't find some CRT functions it needs.

That's only a guess, not even knowing what the actual errors were. Probably it should compile without that compiler switch (but with the include path), too.

Seeing that you build a MinGW program (using -mno-cygwin), I wonder why you don't use MinGW in the first place. Other than Cygwin, MinGW is officially supported by Code::Blocks.

JSeb:
Thank you Thomas!


--- Quote from: thomas on December 02, 2007, 08:40:30 pm ---That's only a guess, not even knowing what the actual errors were. Probably it should compile without that compiler switch (but with the include path), too.

--- End quote ---
Well, you're right. It does compile without the switch (of course, the .exe complains about not finding cygwin1.dll). I don't know why  :(


--- Quote from: thomas on December 02, 2007, 08:40:30 pm ---Seeing that you build a MinGW program (using -mno-cygwin), I wonder why you don't use MinGW in the first place. Other than Cygwin, MinGW is officially supported by Code::Blocks.

--- End quote ---
I'm using Cygwin because I'm using development libraries I was not able to install under Mingw. That's another story. The point is, CB supports GNU GCC, so it should work with Cygwin.

I would be grateful if anyone could tell how to configure CB to work properly with cygwin.

thomas:
Well, either with the include path and without the switch, or without the include path and with the switch :)

Note that compiling without the switch links against the cygwin library which makes your program GPL bound.

JSeb:

--- Quote from: thomas on December 02, 2007, 10:26:38 pm ---Well, either with the include path and without the switch, or without the include path and with the switch :)

--- End quote ---
Makes sense :oops:. I'll go with that and hope I won't have any problems later on. You see, I believe YOU understand what's happening here. I sorry to say I don't quite get it. That's the problem when you spend too much time with Visual Studio: you don't quite remember what goes on behind the scene (linking? yeah, I've seen that in my CS class...).

So... maybe I might ask about the other tabs under Settings->Compiler and Debugger->Global Compiler Settings->Search directories? currently, Linker only contains path C:\Cygwin\lib, and Resource compiler contains C:\Cygwin\usr\include (Compiler is now empty). I know I can at least compile my hello world code, but does that setting makes sense for projects that are a little bit more ambitious?

Thank you so much!

Navigation

[0] Message Index

[#] Next page

Go to full version