cygwin and visual studio.

J

JustSomeGuy

I'm writing a socket class using unix flavor sockets. I'm developing on
win2k with M$ visual studio 6.0.
I have cygwin installed and would like to use its socket header files:

#ifdef UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else // Windows.
#include </cygwin/usr/include/sys/types.h>
#include </cygwin/usr/include/sys/socket.h>
#include </cygwin/usr/include/netinet/in.h>
#endif

Now MS has types defined so I've made sure that the cygwin types is used.

My question is:
1) Should I have simply set up an include search path to cygwin for
types.h,socket.h and in.h?
2) cygwin includes _ansi.h which is also in /cywin/user/include so I guess i
need that in my include search path. How do I resolve the conflict between
the two systems?
 
E

Ekkehard Morgenstern

Hi JustSomeGuy,

JustSomeGuy said:
2) cygwin includes _ansi.h which is also in /cywin/user/include so I guess i
need that in my include search path. How do I resolve the conflict between
the two systems?

The best solution would be to use Cygwin's C++ Compiler (GCC, "g++" command,
use the Cygwin command line window to compile).

Using Visual C++ with the Cygwin libraries and includes might not work
(since they're designed for GCC). The Visual C++ linker does understand the
UNIX library formats, however. In your project settings or compiler/linker
command line options, you have to turn off default library and include path
search and point those to Cygwin's directories.

Another option is to use the WinSock1 interface (declared in WinSock2.h,
documented in the Windows API documentation that came with Visual C++ or in
the Platform SDK). It is roughly compatible with the UNIX interfaces, might
require some conditional code though, especially select() calls are handled
a bit differently than on UNIXes. This way, there'd be no need to use the
Cygwin libraries or includes.

I hope that helps.

Regards,
Ekkehard Morgenstern.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top