From hb at maths.lth.se  Mon Feb 13 15:48:19 2006
From: hb at maths.lth.se (Henrik Bengtsson)
Date: Mon, 13 Feb 2006 15:48:19 +0100
Subject: [Rd] MinGW and the ld bug
Message-ID: <59d7961d0602130648i782671cmb5e782e8334b4138@mail.gmail.com>

Hi.

I noticed that Brian Ripley found and corrected a bug in MinGW's
ld.exe, see http://www.murdoch-sutherland.com/Rtools/.  Thanks for
this.  I wonder if this is the same bug that cause my problems.  I
have tiny toy package with C code that installs perfectly on R Version
2.2.1 beta (2005-12-18 r36792) [this version was mislabelled "beta"
the first few hours on CRAN when the stable 2.2.1 version first came
out].  However, when I try to install the same on R Version 2.2.1
Patched (2006-02-09 r37305) as well as R Version 2.3.0 Under
development (unstable) (2006-02-02 r37243), I get the following error:

C:\Documents and Settings\hb\braju.com.R\R.native\build>Rcmd install R.native

---------- Making package R.native ------------
  adding build stamp to DESCRIPTION
  making DLL ...
making rowMedians.d from rowMedians.c
gcc   -IC:/PROGRA~1/R/R-2.2.1pat/include -Wall -O2   -c rowMedians.c -o rowMedia
ns.o
ar cr R.native.a rowMedians.o
ranlib R.native.a
windres --include-dir C:/PROGRA~1/R/R-2.2.1pat/include  -i R.native_res.rc -o R.
native_res.o
gcc  --shared -s  -o R.native.dll R.native.def R.native.a R.native_res.o  -LC:/P
ROGRA~1/R/R-2.2.1pat/src/gnuwin32   -lg2c -lR
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: R.native.d
ef:1: syntax error
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe:R.native.de
f: file format not recognized; treating as linker script
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe:R.native.de
f:1: syntax error
collect2: ld returned 1 exit status
make[3]: *** [R.native.dll] Error 1
make[2]: *** [srcDynlib] Error 2
make[1]: *** [all] Error 2
make: *** [pkg-R.native] Error 2
*** Installation of R.native failed ***

Removing 'C:/PROGRA~1/R/R-2.2.1pat/library/R.native'
Restoring previous 'C:/PROGRA~1/R/R-2.2.1pat/library/R.native'

My R.native.def looks like this:

LIBRARY R.native.dll
EXPORTS
 rowMedians
 rowMediansInteger
 rowMediansReal

I've tried to replace the two occurances of ld.exe in MINGW with BR's
patch, but I get the same error.  The ld of the patch and the original
one show the same version string;
patch: GNU ld version 2.16.91 20050827 and original: GNU ld version
2.16.91 20050827. I've tried to use both MINGW v5.0.0 and v5.0.2 with
both "current" (v3.4.2) and "candidate" (v3.4.4) packages.

Is this related to the bug BR found?  Any suggestions what might go
wrong between R v2.2.1 and v2.2.1 patched?

Thanks

Henrik



[Rd] MinGW and the ld bug
Henrik Bengtsson