Code::Blocks Forums

User forums => Help => Topic started by: ecare on September 12, 2007, 07:06:27 pm

Title: [just installed, problems to compile]
Post by: ecare on September 12, 2007, 07:06:27 pm
Bonjour,

I've just downloaded code::block,
it works fine to open a file.c and for writing over the code but it doesn't compile!

here is what I get...

Compiling: serveur.c
serveur.c:5:24: sys/socket.h: No such file or directory
serveur.c:7:24: netinet/in.h: No such file or directory
serveur.c:8:19: netdn.h: No such file or directory
serveur.c:10: error: variable `sockaddr_in sin' has initializer but incomplete type
serveur.c:10: error: `AF_INET' was not declared in this scope
serveur.c:12: error: expected `,' or `;' before "void"
serveur.c:55:3: warning: no newline at end of file
serveur.c:10: error: storage size of `sin' isn't known
Process terminated with status 1 (0 minutes, 0 seconds)
7 errors, 1 warnings
 
I run two O.S. and with ubuntu no problems but my laptop is XP and it does not work!
So you see compiling does not recognize librairies that gcc do
And errors appears

PLEASE HELP!
Title: Re: [just installed, problems to compile]
Post by: XayC on September 12, 2007, 07:25:34 pm
Edit: Ok this is wrong, sorry.
Seems you don't have MinGW on your system, make sure you have it, and also that Code::Blocks is looking in the right place.
"Settings" -> "Compiler and debugger settings" -> "Toolchain Executables" check that is pointing to your MinGW directory.

You may find more info in the CB wiki:
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_nightly_build_on_Windows (http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_nightly_build_on_Windows)
http://wiki.codeblocks.org/index.php?title=MinGW_installation (http://wiki.codeblocks.org/index.php?title=MinGW_installation)

Regards, XayC
Title: Re: [just installed, problems to compile]
Post by: MortenMacFly on September 12, 2007, 07:46:34 pm
serveur.c:5:24: sys/socket.h: No such file or directory
serveur.c:7:24: netinet/in.h: No such file or directory
serveur.c:8:19: netdn.h: No such file or directory
Those files are *not* part of the MinGW package. They implement unix/berekley sockets which has not been ported. You now have the following options:
1.) Use Cygwin API - unix sockets are available in this environment but then you will depend on the Cygwin layer (DLL).
2.) Use Windows sockets (WinAPI) but you have to modify the code heavily.
3.) Use another socket implementation that is capable of providing unix sockets (emulation) on Windows. Google for such.

With regards, Morten.
Title: Re: [just installed, problems to compile]
Post by: ecare on September 16, 2007, 10:00:09 pm
bonjour,
thanks for your help Morten and XayC!!!

I'll try and get back to you...

bye
Title: Re: [just installed, problems to compile]
Post by: Jenna on September 16, 2007, 10:53:28 pm
Perhaps you want to give the wxWidgets socket implementation a try? It should work on Win and on linux.
I would be interested in experience with this class, because I have to write a server/client to communicate between a web-application and several Beckhoff Bus Terminal Controllers over Tcp/Ip .
Title: Re: [just installed, problems to compile]
Post by: Ceniza on September 16, 2007, 11:39:41 pm
Windows and *nix sockets are quite similar. You just need to include the right header files and link against the right libraries for each platform. Oh, you also need to initialize and destroy a special type of variable in Windows.

If you want, you can use and/or check an implementation I made that works in both Windows and *nix with an interface similar to that provided by wxWidgets. Just go here (http://svn.cenizasoft.cjb.net/), click on BattleCS, then Utils, and, finally, socket.hpp.