C Socket Programming with CygWin
Asked 14 years, 2 months ago Modified 6 years, 1 month ago Viewed 16k times
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-
4 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?
c sockets cygwin
Share Improve this question Follow asked Nov 12, 2010 at 6:45
LightBulb
41 1 1 2
They don't show up under /usr/include ? – Ignacio Vazquez-Abrams Nov 12, 2010 at 7:03
yes, they are where they're supposed to be, under /usr/include/sys, netinet... but compiler doesnt find
them? – LightBulb Nov 12, 2010 at 7:12
Try reinstalling the compiler, it's clearly a broken install. – Steve-o Nov 13, 2010 at 14:52
5 Answers Sorted by: Highest score (default)
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-
4
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.
NOW, try with a socket program involving sys/socket.h ... I HOPE IT WILL WORK ... :-)..
Share Improve this answer Follow answered Aug 1, 2017 at 3:16
siva
51 3
This must be an accepted answer. Still valid in 2024 – Mike Apr 18, 2024 at 17:07
Try using the -I compiler command line option to specify a path to the header files.
My local reference states
1
-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 .
Share Improve this answer Follow answered Nov 12, 2010 at 8:09
Niels Castle
8,069 37 58
At least on my cygwim they are in
/usr/include/sys and /usr/include/netinet
0
Share Improve this answer Follow answered Nov 12, 2010 at 7:07
James Anderson
27.5k 7 54 80
I also had the same problem. I've resolved to review the compile options.
NG:
0
$ 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
Share Improve this answer Follow answered Apr 28, 2014 at 7:42
user3580382
1
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
0
./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. :)
Share Improve this answer Follow answered Dec 1, 2018 at 15:26
Pierce D'souza
11 2