[R] Compiling Fortran Subroutines as R Shared Objects on Mac OS-X

Chad R. Bhatti bhatticr at yahoo.com
Wed Apr 15 03:36:32 CEST 2009


Hello,

I am trying to compile some F77 subroutines as shared objects for R on my Mac.
--> Mac OS-X Version 10.4.11 (Tiger Intel Mac)


I have done this (successfully) before on Sun Solaris and Linux Fedora systems using the following command.
> R CMD SHLIB myfile.f

I have g77 installed from this page.
http://hpc.sourceforge.net/

I am using R 2.8.1, and I have installed all 4 additional packages including gfortran.

When I try to compile my subroutines (which worked on two other systems), I get the following error.  (I have also tried a very simple subroutine and produced the same error message.)

chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ R CMD SHLIB two.f
gfortran -arch i386   -fPIC  -g -O2 -c two.f -o two.o
gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o two.so two.o  -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
/usr/bin/libtool: for architecture cputype (16777223) cpusubtype (3) object: /usr/local/lib/libgfortran.dylib malformed object (unknown load command 4)
/usr/bin/libtool: for architecture cputype (16777223) cpusubtype (3) object: /usr/local/lib/libgcc_s.10.4.dylib malformed object (unknown load command 4)
make: *** [two.so] Error 1
chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ which g77
/usr/local/bin/g77
chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ which gfortran/usr/local/bin/gfortran



Would anyone happen to understand this error?  The words "malformed object" and "cpusubtype" concern me.

Note:  I am much more of a Unix user than administrator.  I have very limited administrator knowledge and vocabulary.  

I appreciate any help.

Many Thanks,

Chad R. Bhatti




More information about the R-help mailing list