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> #else #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #ifdef HAVE_BSD_NETWORKING #include <netdb.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #endif #endif 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 ---------- Making package WINRPACK ------------ adding build stamp to DESCRIPTION making DLL ... making win2R.d from win2R.c making win2asc.d from win2asc.c gcc-sjlj -std=gnu99 -Id:/Rcompile/recent/R-26~1.2/include -O3 -Wall -c win2R.c -o win2R.o win2R.c:21:24: error: sys/socket.h: No such file or directory win2R.c:22:24: error: netinet/in.h: No such file or directory win2R.c:23:23: error: arpa/inet.h: No such file or directory win2R.c: In function 'read_data': win2R.c:591: warning: implicit declaration of function 'ntohl' win2R.c: In function 'read_one_sec': win2R.c:723: warning: implicit declaration of function 'ntohs' make[3]: *** [win2R.o] Error 1 make[2]: *** [srcDynlib] Error 2 make[1]: *** [all] Error 2 make: *** [pkg-WINRPACK] Error 2 *** Installation of WINRPACK failed *** -- ========================================== 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 [EMAIL PROTECTED] http://www.unc.edu/~leesj ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.