From danlipsitt at gmail.com  Wed Jun 14 23:36:02 2006
From: danlipsitt at gmail.com (Dan Lipsitt)
Date: Wed, 14 Jun 2006 17:36:02 -0400
Subject: [Rd] package compile error on RHEL x86_64
Message-ID: <b3a7efa90606141436v12d1d05byf46fa7a0b90f4ff6@mail.gmail.com>

I am unable to install the gmp package on an x86_64 (Xeon) machine. I
have had the same problem with other packages (eg. MCMCpack) as well.
I am running Red Hat Enterprise Linux 4.1.
I get the following error:

g++ -shared -L/usr/local/lib64 -o gmp.so biginteger.o
biginteger_operator.o bigintegerR.o bigrational.o
bigrational_operator.o bigrationalR.o factor.o -L/usr/local/lib/ -lgmp
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a(functexcept.o):
relocation R_X86_64_32 against `std::bad_exception::~bad_exception()'
can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a: could not read
symbols: Bad value

However, I have found that if I run "R CMD SHLIB" twice in the src/
directory, once to build the .o files, and once to link, I can build
the shared library. If I run it on the .o files instead of the .cc
files it uses gcc instead of g++. This appears to be the change that
allows the lib to build. "-fPIC" seems to have nothing to do with it.

So my question is: How do I get "R CMD INSTALL" to link with gcc
instead of g++? I have tried adding "LINK.cc = $(LINK.c)" to the top
of src/Makevars.in and then running "R CMD check" in the top dir of
the package, but it uses g++ anyway. Any other fix or workaround
suggestions would be appreciated as well.

A commandline transcript follows below.

Thanks,
Dan

$ sudo R CMD INSTALL gmp_0.3-4.tar.gz
* Installing *source* package 'gmp' ...
creating cache ./config.cache
checking for __gmpz_ui_sub in -lgmp... yes
updating cache ./config.cache
creating ./config.status
creating src/Makevars
** libs
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c biginteger.cc -o biginteger.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c biginteger_operator.cc -o
biginteger_operator.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c bigintegerR.cc -o
bigintegerR.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c bigrational.cc -o
bigrational.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c bigrational_operator.cc -o
bigrational_operator.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c bigrationalR.cc -o
bigrationalR.o
g++ -I/usr/lib/R/include -I/usr/local/include/  -Wno-conversion
-I/usr/local/include   -fPIC  -O2 -g -c factor.cc -o factor.o
g++ -shared -L/usr/local/lib64 -o gmp.so biginteger.o
biginteger_operator.o bigintegerR.o bigrational.o
bigrational_operator.o bigrationalR.o factor.o -L/usr/local/lib/ -lgmp
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a(functexcept.o):
relocation R_X86_64_32 against `std::bad_exception::~bad_exception()'
can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a: could not read
symbols: Bad value
collect2: ld returned 1 exit status
make: *** [gmp.so] Error 1
ERROR: compilation failed for package 'gmp'

$ tar xzf gmp_0.3-4.tar.gz
$ cd gmp/src
$ R CMD SHLIB *.cc
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
biginteger.cc -o biginteger.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
biginteger_operator.cc -o biginteger_operator.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
bigintegerR.cc -o bigintegerR.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
bigrational.cc -o bigrational.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
bigrational_operator.cc -o bigrational_operator.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
bigrationalR.cc -o bigrationalR.o
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -c
factor.cc -o factor.o
g++ -shared -L/usr/local/lib64 -o biginteger.so biginteger.o
biginteger_operator.o bigintegerR.o bigrational.o
bigrational_operator.o bigrationalR.o factor.o
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a(functexcept.o):
relocation R_X86_64_32 against `std::bad_exception::~bad_exception()'
can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/3.4.3/libstdc++.a: could not read
symbols: Bad value
collect2: ld returned 1 exit status
make: *** [biginteger.so] Error 1
$ R CMD SHLIB *.o
gcc -shared -L/usr/local/lib64 -o biginteger.so biginteger.o
biginteger_operator.o bigintegerR.o bigrational.o
bigrational_operator.o bigrationalR.o factor.o
$



[Rd] package compile error on RHEL x86_64
Dan Lipsitt