[R] package compilation: including external libraries in windows compilation

From: Jonathan Lees <jonathan.lees_at_unc.edu>
Date: Fri, 25 Apr 2008 09:34:30 -0400

Dear R package developers:

I need help on getting a package compiled for windows. I am trying to use definitions and routines from a set of libraries in that are in LINUX under
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

but these are unavailable in windows.
I found that we can get these by including, in windows these includes:

#include <winsock2.h>
#include <io.h>

My problem is I do not know how to instruct the preprocessor to include the linux .h files
when in linux and the windows one in windows.

I thought I found a solution online by using:

#if defined(Win32)
#include <winsock2.h>
#include <io.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

But I still get an error when these are compiled on the R-distribution. I do not understand where I am supposed to set the Win32 flag so that it will be ignored in LINUX but used in windows. where is "Win32" "HAVE_UNISTD_H" and "HAVE_BSD_NETWORKING" set?

It seems that Makevars.win would be logical place, but I do not see how to do this.

Thanks for any help.

Jonathan Lees

Prof. Jonathan M. Lees
Department of Geological Sciences
CB #3315, Mitchell Hall
University of North Carolina
Chapel Hill, NC  27599-3315
(919) 962-0695
FAX (919) 966-4519


R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 25 Apr 2008 - 13:55:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Apr 2008 - 15:00:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive