[R-SIG-Mac] Compiling 2.5.1 on OSX Panther (James Kyle)

James Kyle krunk7 at gmail.com
Mon Aug 13 22:11:28 CEST 2007


Thank you for the input, I'm a bit new to this level of compiling,  
but here's my best efforts.


> Unfortunately I'm currently traveling without access to any Panther
> box, so I can help you only theoretically. The problem is that you're
> using static g2c and thus linking it more than once (libR and
> libRlapack) won't work. There are several work arounds:
> 1) use dynamic g2c (if available)
>
I read the gcc documentation and the only package not compiled as a  
shared lib by default is libobjc. So I first compiled gcc-3.3.6  
(without the --enable-shared=libobjc), installed it in /usr/local/ 
gcc36, and then ln -sf /usr/local/gcc36/bin/gcc ~/bin/gcc and ln -sf / 
usr/local/gcc36/bin/g77 ~/bin/g77.
Compiling R against this build produced:

$ ./configure --with-blas='-framework vecLib' --enable-BLAS-shlib &&  
make all
g77  -fPIC -fno-common  -g -O2 -c blas.f -o blas.o
g77  -fPIC -fno-common  -g -O2 -c cmplxblas.f -o cmplxblas.ogcc - 
std=gnu99 -dynamiclib -L/sw/lib -L/usr/local/lib -o libRblas.dylib  
blas.o -install_name libRblas.dylib -headerpad_max_install_names  - 
lg2c  cmplxblas.o
ld: for architecture ppc
ld: Undefined symbols:
_xerbla_
_z_abs
/usr/bin/libtool: internal link edit command failed
make[4]: *** [libRblas.dylib] Error 1
make[4]: Leaving directory `/opt/sandbox/R-2.5.1/src/extra/blas'
make[3]: *** [R] Error 2
make[3]: Leaving directory `/opt/sandbox/R-2.5.1/src/extra/blas'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/opt/sandbox/R-2.5.1/src/extra'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/opt/sandbox/R-2.5.1/src'
make: *** [R] Error 1

Next, I attempted to compile gcc36 with --enable-shared=libobjc
(after all this is OSX, so I figured this might do it). Compiling  
against this build produces the same errors as above.


> 2) use --without-lapack (possibly --without-blas)
>
This seemed the most straight forward solution, but it too produces  
errors

$ ./configure --without-lapack && make all
gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../ 
src/extra/pcre  -I. -I../../src/include -I../../src/include -I/sw/ 
include -I/usr/local/include -DHAVE_CONFIG_H   -fPIC -fno-common  -g - 
O2 -c complex.c -o complex.o
complex.c: In function `do_cmathfuns':
complex.c:332: error: incompatible type for argument 1 of `cabs'
make[3]: *** [complex.o] Error 1
make[3]: Leaving directory `/opt/sandbox/R-2.5.1/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/opt/sandbox/R-2.5.1/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/opt/sandbox/R-2.5.1/src'
make: *** [R] Error 1

and:

$ ./configure --without-lapack --without-blas && make all

gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../ 
src/extra/pcre  -I. -I../../src/include -I../../src/include -I/sw/ 
include -I/usr/local/include -DHAVE_CONFIG_H   -fPIC -fno-common  -g - 
O2 -c complex.c -o complex.o
complex.c: In function `do_cmathfuns':
complex.c:332: error: incompatible type for argument 1 of `cabs'
make[3]: *** [complex.o] Error 1
make[3]: Leaving directory `/opt/sandbox/R-2.5.1/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/opt/sandbox/R-2.5.1/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/opt/sandbox/R-2.5.1/src'
make: *** [R] Error 1

Same errors were produced with the --enable-shared=libobjc build of  
gcc as well.


> 3) link libRlapack manually without g2c (it should be available
> through libR anyway)
>
>
I'm not entirely sure how to go about this. I found the  
libRlapack.dylib compile command in the $R/src/modules/lapack/ 
Makefile on line #81

$(DYLIB_LINK) -o $@ $(LIBOBJECTS) -install_name libRlapack.dylib - 
compatibility_version 2.5.0 -current_version 2.5.1  - 
headerpad_max_install_names -L$(R_HOME)/lib$(R_ARCH) -lRblas $ 
(Rlapack_la_LIBADD)

This is expanded to:

gcc -std=gnu99 -dynamiclib -L/sw/lib -L/usr/local/lib -o  
libRlapack.dylib dlamch.o dlapack0.o dlapack1.o dlapack2.o dlapack3.o  
dlapack4.o cmplx.o -install_name libRlapack.dylib - 
compatibility_version 2.5.0 -current_version 2.5.1  - 
headerpad_max_install_names -L../../../lib -lRblas -lg2c -L../../../ 
lib -lR -dylib_file libRblas.dylib:../../../lib/libRblas.dylib

I attempted to remove the -lg2c, which threw and error on not finding  
-lRblas. Removing that throws an error on not finding -lR. So I must  
not be going about this correctly.

> Cheers,
> Simon
>
>

Thanks for the suggestions, Simon. Much appreciated. :)

James A. Kyle

>
> On Aug 10, 2007, at 6:02 PM, James Kyle wrote:
>
>
>> This seems to be the problem area:
>>
>>
>>> ld: common symbols not allowed with MH_DYLIB output format with the
>>> -multi_module option
>>> /usr/local/lib/libg2c.a(err.o) definition of common _f__cblank
>>> (size 4)
>>> /usr/local/lib/libg2c.a(fmt.o) definition of common _f__cnt (size  
>>> 40)
>>> /usr/local/lib/libg2c.a(fmt.o) definition of common f(char,  *)
>>> (size 4)
>>> /usr/local/lib/libg2c.a(err.o) definition of common f(char, long *,
>>> short __restrict) (size 4)
>>> /usr/local/lib/libg2c.a(err.o) definition of common _f__cursor
>>> (size 4)
>>>
>>>
>>
>> It goes on to list the other common symbols found in libg2c.a.
>> libg2c.a is a library provided by the g77 libraries.
>>
>> So I checked out "$ man ld" to find out about this pesky -
>> multi_module option and also poked around and found some references
>> to MH_DYLIB and some other interesting options like -undefined.
>>
>> Particularly, under the heading TWO-LEVEL AND FLAT NAMESPACES, three
>> paragraphs down we see the default for static link editor is -
>> twolevel_namespace which requires that all undefined references be
>> satisfied at static link time. Also, the ability to suppress these
>> errors is disabled (-undefined suppress).
>>
>> I assume that what's going on is some of the global variables in / 
>> usr/
>> local/lib/libg2c.a are defined but not instantiated. So they need to
>> be explicitly set as externs or set to some default value. Since the
>> ability to suppress errors isn't available when compiling the
>> libRlapack.dylib, then it must be changed in libg2c.a....that entails
>> recompiling gfortran.
>>
>>
>> I'm not clear on why the same code compiles on 10.4 unless gfortran
>> 4.x. doesn't do this. Anyway, I downloaded the 3.4.2 gcc source and
>> looked for err.c with f__cblank var declared (the first error):
>>
>>
>>> /usr/local/lib/libg2c.a(err.o) definition of common _f__cblank
>>> (size 4)
>>>
>>
>> It seems there were some major changes in fortran between 3.x and 4.x
>> as the above variables don't exist and even directory structures are
>> different. For example, f__cblank and f__cnt don't exist in 4.x. Nor
>> does the libf2c directory where libg2c.a is compiled in 3.x.
>>
>> That's a wrap for  me today, but I'll try to compile a version of
>> libg2c.a without the common symbol errors on Monday.
>>
>> As always, if any developers or those more familiar with the code
>> base would like to chime in and direct, correct, refute, or suggest.
>> It'd be very appreciated.
>>
>>
>> -james kyle
>> On Aug 10, 2007, at 7:14 AM, Ulf Martin wrote:
>>
>>
>>> Hi
>>>
>>> James R. Milks schrieb:
>>>
>>>> You can find the compiled version of R 2.5.1 for OS 10.4.4 or  
>>>> higher
>>>> at http://cran.r-project.org/bin/macosx/.  I try not to get into
>>>> compiling myself as I've had pretty bad luck with doing
>>>> compilations.
>>>>
>>>
>>> I think the problem is, that the binaries are for OS 10.4.x =
>>> "Tiger",
>>> they don't work on 10.3.y = "Panther". So this tip won't help. Two
>>> month
>>> ago I also tried to compile the new R version (2.5.0 then) on  
>>> Panther
>>> without success. So I am still hanging around with R 2.4.1. :-(
>>>
>>> Just a guess, as I have no idea what's really going on: The
>>> compilation
>>> fails making lapack stuff. Now, since lapack is a Fortran 77
>>> package the
>>> problem might have something to do with this?! (My compilation also
>>> failed at this point.)
>>>
>>>
>>>> On Aug 9, 2007, at 3:04 PM, krunk7 at gmail.com wrote:
>>>>
>>>>>
>>>>> I'm attempting to compile R 2.5.1 on OSX Panther and have run into
>>>>> some issues. First off, if anyone has a link to a binary build of
>>>>> 2.5.1 for Panther I have no issue going that route.
>>>>>
>>>>> -) gcc version 3.3 20030304 (Apple Computer, Inc. build 1666)
>>>>> -) g77 version 3.4.2
>>>>> -) ./configure --with-blas='-framework vecLib' --with-lapack
>>>>> R_PAPERSIZE=letter F77=g77
>>>>>
>>>>> When first seeing the build issues, I wanted to verify that I have
>>>>> the necessary basic environment. I grabbed the 2.2.1 sources,  
>>>>> which
>>>>> are the latest version available with a binary for Panther, and
>>>>> they
>>>>> compiled without a hitch.
>>>>>
>>>>> The error appears in the lapack module when building
>>>>> libRlapack.dylib. Error output is:
>>>>>
>>>>>
>>>>>> make[4]: Entering directory `/opt/sandbox/R-2.5.1/src/modules/
>>>>>> lapack'
>>>>>> gcc -std=gnu99 -dynamiclib -L/sw/lib -L/usr/local/lib -o
>>>>>> libRlapack.dylib dlamch.o dlapack0.o dlapack1.o dlapack2.o
>>>>>> dlapack3.o dlapack4.o cmplx.o -install_name libRlapack.dylib -
>>>>>> compatibility_version 2.5.0 -current_version 2.5.1  -
>>>>>> headerpad_max_install_names  -L/usr/local/lib/gcc/powerpc-apple-
>>>>>> darwin6.8/3.4.2 -lg2c -L../../../lib -lR
>>>>>> /usr/bin/libtool: internal link edit command failedld: warning
>>>>>> multiple definitions of symbol _z_abs/usr/local/lib/libg2c.a
>>>>>> (z_abs.o) definition of _z_abs in section  
>>>>>> (__TEXT,__text)../../../
>>>>>> lib/libR.dylib(z_abs.o) definition of _z_absld: warning multiple
>>>>>> definitions of symbol _f__cabs/usr/local/lib/libg2c.a(cabs.o)
>>>>>> definition of _f__cabs in section (__TEXT,__text)../../../lib/
>>>>>> libR.dylib(cabs.o) definition of _f__cabsld: common symbols not
>>>>>> allowed with MH_DYLIB output format with the -multi_module  
>>>>>> option/
>>>>>> usr/local/lib/libg2c.a(err.o) definition of common _f__cblank
>>>>>> (size
>>>>>> 4)/usr/local/lib/libg2c.a(fmt.o) definition of common _f__cnt
>>>>>> (size
>>>>>> 40)/usr/local/lib/libg2c.a(fmt.o) definition of common f 
>>>>>> (char,  *)
>>>>>> (size 4)/usr/local/lib/libg2c.a(err.o) definition of common f
>>>>>> (char,
>>>>>> long *, short __restrict) (size 4)/usr/local/lib/libg2c.a(err.o)
>>>>>> definition of common _f__cursor (size 4)/usr/local/lib/libg2c.a
>>>>>> (err.o) definition of common _f__doed (size 4)/usr/local/lib/
>>>>>> libg2c.a(err.o) definition of common _f__doend (size 4)/usr/ 
>>>>>> local/
>>>>>> lib/libg2c.a(err.o) definition of common _f__doned (size 4)/usr/
>>>>>> local/lib/libg2c.a(err.o) definition of common _f__dorevert (size
>>>>>> 4)/usr/local/lib/libg2c.a(err.o) definition of common _f__elist
>>>>>> (size 4)/usr/local/lib/libg2c.a(err.o) definition of common
>>>>>> _f__fmtbuf (size 4)/usr/local/lib/libg2c.a(err.o) definition of
>>>>>> common _f__fmtlen (size 4)/usr/local/lib/libg2c.a(err.o)
>>>>>> definition
>>>>>> of common _f__init (size 4)/usr/local/lib/libg2c.a(fmt.o)
>>>>>> definition of common _f__nonl (size 4)/usr/local/lib/libg2c.a
>>>>>> (fmt.o) definition of common _f__parenlvl (size 4)/usr/local/lib/
>>>>>> libg2c.a(fmt.o) definition of common f(char *) (size 4)/usr/ 
>>>>>> local/
>>>>>> lib/libg2c.a(fmt.o) definition of common _f__ret (size 40)/usr/
>>>>>> local/lib/libg2c.a(fmt.o) definition of common _f__revloc (size
>>>>>> 4)/
>>>>>> usr/local/lib/libg2c.a(fmt.o) definition of common f(long double,
>>>>>> *) (size 4)/usr/local/lib/libg2c.a(err.o) definition of common
>>>>>> _f__scale (size 4)/usr/local/lib/libg2c.a(fmt.o) definition of
>>>>>> common _f__workdone (size 4)/usr/local/lib/libg2c.a(err.o)
>>>>>> definition of common _f__units (size 4800)/usr/local/lib/libg2c.a
>>>>>> (err.o) definition of common f(char, float) (size 4)/usr/local/
>>>>>> lib/
>>>>>> libg2c.a(err.o) definition of common _f__curunit (size 4)/usr/
>>>>>> local/
>>>>>> lib/libg2c.a(err.o) definition of common _f__donewrec (size 4)/
>>>>>> usr/
>>>>>> local/lib/libg2c.a(err.o) definition of common _f__external (size
>>>>>> 4)/usr/local/lib/libg2c.a(err.o) definition of common
>>>>>> _f__formatted
>>>>>> (size 4)/usr/local/lib/libg2c.a(err.o) definition of common
>>>>>> _f__hiwater (size 4)/usr/local/lib/libg2c.a(err.o) definition of
>>>>>> common _f__putn (size 4)/usr/local/lib/libg2c.a(err.o) definition
>>>>>> of common _f__reading (size 4)/usr/local/lib/libg2c.a(err.o)
>>>>>> definition of common _f__recpos (size 4)/usr/local/lib/libg2c.a
>>>>>> (err.o) definition of common _f__sequential (size 4)/usr/local/
>>>>>> lib/
>>>>>> libg2c.a(err.o) definition of common _f__getn (size 4)/usr/local/
>>>>>> lib/libg2c.a(err.o) definition of common _f__icptr (size 4)/usr/
>>>>>> local/lib/libg2c.a(err.o) definition of common f(short, void,  
>>>>>> int,
>>>>>> char) (size 4)
>>>>>> make[4]: *** [libRlapack.dylib] Error 1  make[4]: Leaving
>>>>>> directory
>>>>>> `/opt/sandbox/R-2.5.1/src/modules/lapack'make[3]: *** [R] Error
>>>>>> 2make[3]: Leaving directory `/opt/sandbox/R-2.5.1/src/modules/
>>>>>> lapack'make[2]: *** [R] Error 1make[2]: Leaving directory `/opt/
>>>>>> sandbox/R-2.5.1/src/modules'make[1]: *** [R] Error 1make[1]:
>>>>>> Leaving directory `/opt/sandbox/R-2.5.1/src'make: *** [R] Error 1
>>>>>>
>>>
>>> _______________________________________________
>>> R-SIG-Mac mailing list
>>> R-SIG-Mac at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>
>>
>>
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list