Reputation: 10410
I'm trying to compile a C program that I downloaded off the internet using cl.exe at the command line in Windows. This file includes gnu C library files such as getopt.h and unistd.h, which are not available by default under Windows. How can I gain access to these (while still using the cl.exe compiler).
Thanks.
Upvotes: 0
Views: 4007
Reputation: 66672
getopt.c
from MinGW will fairly trivially port to MS C (I've done this with VS2005). You can get it from the MinGW web site. This Stackoverflow posting discusses substituting for unistd.h
on MS C Compilers.
Upvotes: 1
Reputation: 1361
The files getopt.h and unistd.h are header files. It is better to uses a gnu compatible compiler like MINGW32. Since replacing this files is in general not enough to get your library compiling and running under a windows-compiler. If you still want to use cl.exe then replace "unistd.h" by "windows.h" and get the win32 compatible "getopt" from the internet.
Upvotes: 3
Reputation: 84189
There's always cygwin - use the include files and link with the cygwin1.dll
library, here's their FAQ entry on this.
Upvotes: 2
Reputation: 98398
unistd.h is standard C include file. I would be shocked if whatever compiler you are using doesn't provide it. Are you sure it isn't there?
Upvotes: 0
Reputation: 1873
For getopt.h you can use xgetopt. If you are interested in changing compilers there is always MingW. Otherwise, you'll probably have to write your own getopt.h or unistd.h.
Upvotes: 3
Reputation:
getopt.h and unistd.h are not libraries - they are header files. Even if you had them they would be useless to you as you would also need the actual binary libraries (.LIB or .a files). The unistd.h file as its name suggests, contains declarations of functions specific specific to Unix.
Upvotes: 3