[Rd] Cross compiling a package for Windows on Linux

Douglas Bates bates@stat.wisc.edu
Wed, 26 Apr 2000 18:05:14 -0500 (CDT)


I would like to compile for Windows a rather simple R package that
contains some C code.  It does not contain any Fortran code.

I tried the cross-compilation route using the pre-built set of tools
from http://www.devolution.com/~slouken/SDL/Xmingw32/, as described in
$R_SRC/src/gnuwin32/INSTALL

Using the sources in r-devel from the rsync site I am able to build
libR.a in src/gnuwin32 but I can't build the package.  Using the
sources in r-release-patched from the rsync site I am unable to build
libR.a.  The tail end of that compilation log is

 $ cd r-release/src/gnuwin32/
 $ make
 mkdir -p ../../bin 
 make -C ./fixed
 make[1]: Entering directory `/usr/src/r-release/src/gnuwin32/fixed'
 -------- Building ../../../library/base/R/Rprofile from ../../library/profile/Common.R ../../library/profile/Rprofile.gnw--------
 mkdir -p ../../../library/base/R
 cat  ../../library/profile/Common.R ../../library/profile/Rprofile.gnw > ../../../library/base/R/Rprofile
 sed -e '/^#/d' -e '/Rsockfork/d' -e 's/F77_SUBROUTINE(\(.*\))/void * \1_();/' -e 's/C_FUNCTION(\(.*\))/void * \1();/' ../../appl/ROUTINES > ../../include/FFDecl.h
 sed -e '/^#/d' -e '/Rsockfork/d' -e 's/F77_SUBROUTINE(\(.*\))/	{ "\1_",	\1_},/' -e 's/C_FUNCTION(\(.*\))/{ "\1",	\1 },/' ../../appl/ROUTINES > ../../include/FFTab.h
 sh ./GETCONFIG > ../../include/Rconfig.h
 sh ./GETVERSION > ../../include/Rversion.h
 cp -p ./h/config.h ./h/psignal.h ../../include
 echo done > fixh
 (cd ../../../doc; \
 cat html/search/SearchEngine-head.html > html/search/SearchEngine.html; \
 perl ../src/gnuwin32/fixed/keywords2html KEYWORDS.db >> html/search/SearchEngine.html; \
 cat html/search/SearchEngine-foot.html >> html/search/SearchEngine.html)
 cp -p ./r/*.html ../../../doc/html
 echo done > fixr
 cp -p  bin/Rd2dvi.sh bin/Rd2txt.bat bin/Rdconv.bat bin/Rdindex.bat bin/Sd2Rd.bat bin/fwf2table bin/helpPRINT.bat ../../../bin
 echo done > fixbin
 cp -p etc/Rconsole etc/Rdevga etc/Rprofile etc/rgb.txt ../../../etc
 echo done > fixetc
 ...  (many lines deleted)
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -DHAVE_CONFIG_H  -c zeroin.c -o zeroin.o
 i386-mingw32-g77 -O2 -Wall -pedantic  -c blas.f -o blas.o
 make[1]: i386-mingw32-g77: Command not found
 make[1]: *** [blas.o] Error 127
 make[1]: Leaving directory `/usr/src/r-release/src/appl'
 make: *** [rlibs] Error 2
 $ make libR.a
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c console.c -o console.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c dataentry.c -o dataentry.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c devga.c -o devga.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c dodevga.c -o dodevga.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c dounzip.c -o dounzip.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c dynload.c -o dynload.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c edit.c -o edit.o
 i386-mingw32-gcc -isystem /packages/R-X/i386-mingw32/include   -O2 -Wall -pedantic -I../include -I../include/R_ext -I. -DHAVE_CONFIG_H  -c extra.c -o extra.o
 extra.c: In function `Rwin_fpset':
 extra.c:452: warning: implicit declaration of function `_fpreset'
 extra.c:453: warning: implicit declaration of function `_controlfp'
 extra.c:453: `_MCW_EM' undeclared (first use in this function)
 extra.c:453: (Each undeclared identifier is reported only once
 extra.c:453: for each function it appears in.)
 make: *** [extra.o] Error 1
 $ i386-mingw32-gcc --version
 2.95.2


With the sources from r-devel, which have been changed today, I can
generate libR.a but I cannot build a library, even with libR.a.  I
tried building the nls library just as a test.  The errors reported after 
make pkg-nls are

 $ make pkg-nls
 make DLLNM=  EXTRADOCS= \
   -C /usr/src/r-devel/src/library/nls PKG=nls RHOME=/usr/src/r-devel RLIB=/usr/src/r-devel/library \
   -f /usr/src/r-devel/src/gnuwin32/MakePkg
 make[1]: Entering directory `/usr/src/r-devel/src/library/nls'
 ---------- Making package nls ------------
 mkdir -p /usr/src/r-devel/library/nls
 cp -r   ./DESCRIPTION  ./INDEX  ./TITLE  /usr/src/r-devel/library/nls/
 cp: ./DESCRIPTION: No such file or directory
 make[1]: [/usr/src/r-devel/library/nls/zzzz] Error 1 (ignored)
 make -C ./src RHOME=/usr/src/r-devel \
   -f /usr/src/r-devel/src/gnuwin32/MakeDll DLLNAME=nls
 make[2]: Entering directory `/usr/src/r-devel/src/library/nls/src'
 ------- Building nls.dll from nls.a --------
 echo LIBRARY nls > nls.def
 echo EXPORTS >> nls.def
 i386-mingw32-nm nls.a > Defs
 sed -n "/^........ [BCDRT] _/s/^........ [BCDRT] _/ /p" Defs >> nls.def
 i386-mingw32-gcc  -mdll -Wl,--base-file,nls.b -s  -o nls.dll  nls.a  -L/usr/src/r-devel/src/gnuwin32   -lR 
 i386-mingw32-dlltool -k --as i386-mingw32-as   --dllname nls.dll  --base-file nls.b --output-exp nls.e --def nls.def
 i386-mingw32-gcc  -mdll  -Wl,--base-file,nls.b -s  -o nls.dll nls.e nls.a  -L/usr/src/r-devel/src/gnuwin32   -lR 
 nls.a(nls.o)(.text+0x203):nls.c: undefined reference to `Rf_asLogical'
 nls.a(nls.o)(.text+0x20f):nls.c: undefined reference to `Rf_isNewList'
 nls.a(nls.o)(.text+0x223):nls.c: undefined reference to `Rf_error'
 ...  (many lines deleted)
 nls.a(nls.o)(.text+0xb52):nls.c: undefined reference to `Rf_setAttrib'
 nls.a(nls.o)(.text+0xb5c):nls.c: undefined reference to `Rf_unprotect'
 make[2]: *** [nls.dll] Error 1
 make[2]: Leaving directory `/usr/src/r-devel/src/library/nls/src'
 make[1]: *** [src/nls.dll] Error 2
 make[1]: Leaving directory `/usr/src/r-devel/src/library/nls'
 make: *** [pkg-nls] Error 2

Do I need to go back and build a cross-compiler for g77 and start from
scratch?
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._