Standard practice is probably to always write #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif #if HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif
I have a feeling autoconf gives you those preprocessor definitions for free. The more interesting question is how you get the link libraries right. I do explicit checks for libnsl and libsocket; see http://www.kegel.com/dkftpbench/dkftpbench-0.45/configure.in - Dan -----Original Message----- From: Ollie Cook To: [EMAIL PROTECTED] Sent: 09.10.2002 13:03 Subject: functions in different libraries on different OSes. Hi, I am new to autoconf/automake so my questions may appear naive - apologies if that is the case. I have written some software which I have released, but it is not very portable (currently does not compile under Solaris). One of the reasons for this is that it uses the socket() function. Under FreeBSD this is in libc, and requires the following header files to be included: #include <sys/types.h> #include <sys/socket.h> The same is also true of GNU/Linux. However, under Solaris (SunOS 5.6) you must compile againt -lxnet and include only #include <sys/socket.h> There may be other methods of getting socket() on other OSes, for all I know. What is the correct way to diagnose how to get socket(), or any other function, on a given OS, and to build the software appropriately, using autoconf? Any pointers would be greatly appreciated. Yours, Ollie -- Oliver Cook Systems Administrator, ClaraNET [EMAIL PROTECTED] 020 7903 3065