LightBulb
LightBulb

Reputation: 41

C Socket Programming with CygWin

Hi I'm trying to write a little server / client program in C using CygWin, problem is, the gcc compiler in Cygwin doesn't seem to contain the standard headers assosiated with socket-programming. When trying to compile my server program, i get:

netinet/in.h: No such file or directory
sys/socket.h: No such file or directory
netdb.h: No such file or directory

Are these three headers located elsewhere in the CygWin-enviorment?

Upvotes: 4

Views: 15777

Answers (5)

Pierce D'souza
Pierce D'souza

Reputation: 11

I had this problem for days with the library apophenia . so make sure the libraries you've installed have first been configured with a simple command

./configure

once configured use the following commands to build , Install and check the libraries

all- Builds libraries

install- installs libraries

check-tests the libraries

doc- generate documentation via doxygen

Hope it helps. :)

Upvotes: 0

siva
siva

Reputation: 51

I also had same problem.. i was googling for hours and finally found this... thanks to ralph...

https://ralphexe.wordpress.com/2015/09/09/run-unix-socket-program-in-windows-using-cygwin/

For socket commands you have to include some of the packages in cygwin while installing... (If you have installed try reinstalling ...)

During the installation :

  1. In "SELECT PACKAGES " phase of installation.

  2. Expand DEVEL

  3. select GNU compilers for c and c++

    4.And click next and complete the installation.

enter image description here

NOW, try with a socket program involving sys/socket.h ... I HOPE IT WILL WORK ... :-)..

Upvotes: 4

user3580382
user3580382

Reputation: 1

I also had the same problem. I've resolved to review the compile options.

NG:

$ gcc -mno-cygwin -o echo_server.exe echo_server.c
echo_server.c:12:43: sys/socket.h: No such file or directory
echo_server.c:13:24: netinet/in.h: No such file or directory

OK:

$ gcc -o echo_server.exe echo_server.c

Upvotes: 0

Niels Castle
Niels Castle

Reputation: 8069

Try using the -I compiler command line option to specify a path to the header files.

My local reference states

-I dir
       Add the directory dir to the list of directories to be searched for
       header files.  Directories named by -I are searched before the
       standard system include directories.  If the directory dir is a
       standard system include directory, the option is ignored to ensure
       that the default search order for system directories and the
       special treatment of system headers are not defeated . 

Upvotes: 1

James Anderson
James Anderson

Reputation: 27478

At least on my cygwim they are in

/usr/include/sys and /usr/include/netinet

Upvotes: 0

Related Questions