Skip to Content

Install fortran-based R package on Mac OS X

I'm attempting to install version 1.10 of the cts package from CRAN on OS X, and I'm running into some linker problems. I need to install from source, because I'm making a few changes to the source (actually Zhu Wang, the cts author, made the changes & sent me the new tarball - but the same issue happens with the stock sources of cts on CRAN).

It seems to compile all the sources fine, but then fails with the following errors during linking:

> install.packages('~/Downloads/cts_1.0-11.tar.gz', .libPaths()[1], repos=NULL, type='source')
* installing *source* package ‘cts’ ...
** libs
*** arch - i386
gfortran-4.2 -arch i386   -fPIC  -g -O2 -c a9rntc.f -o a9rntc.o
gfortran-4.2 -arch i386   -fPIC  -g -O2 -c a9rntd.f -o a9rntd.o
gfortran-4.2 -arch i386   -fPIC  -g -O2 -c a9rnti.f -o a9rnti.o
[bunch of other compilation lines snipped ...]
gfortran-4.2 -arch i386   -fPIC  -g -O2 -c u9dmp.f -o u9dmp.o
gfortran-4.2 -arch i386   -fPIC  -g -O2 -c update.f -o update.o
gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o a9rntc.o a9rntd.o a9rnti.o a9rntl.o a9rntr.o balanc.o balinv.o cinvert.o complete.o cspec.o d1mach.o d1rply.o d2rply.o d3rply.o d4rply.o d5rply.o d6rply.o d7rply.o d8rply.o d9rply.o dgetrf.o dgetrs.o display.o dpca.o drpoly.o e9rint.o envirn.o eprint.o fdump.o forecast.o frmatd.o frmati.o frmatr.o getmin.o hqrort.o i0tk00.o i10wid.o i1mach.o i8save.o iceil.o iflr.o isamax.o istkgt.o istkqu.o istkrl.o kfilsm.o kfilsm1.o loop.o lybsc.o lycsr.o mepad.o mutil.o newline.o orthes.o ortran.o rejuce.o repar.o resg0.o resg0new.o resg1d.o resg1dpre.o resg1dpre1.o resgen.o revg1.o roots.o s88fmt.o saxpy.o sdata.o sdot.o sdump.o search.o setcom.o seterr.o setfor.o setkfilsm.o setup1.o setupdate.o simi.o sscal.o stkdmp.o store.o u9dmp.o update.o -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRlapack -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRblas -lgfortran -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: can't find atom for N_GSYM stabs mdeps:G(0,10)=s32base:(0,6),0,64;big:(0,6),64,64;small:(0,6),128,64;eps:(0,6),192,64;; in balanc.o
ld: warning: can't find atom for N_GSYM stabs base:G(0,6) in balanc.o
ld: warning: can't find atom for N_GSYM stabs setcon:G(0,3)=s252cso:(0,4)=r(0,2);8;0;,0,64;csz:(0,4),64,64;lam:(0,4),128,64;ssold:(0,4),192,64;gmold:(0,4),256,64;gmnew:(0,4),320,64;sigsq:(0,4),384,64;oldb:(0,5)=ar(0,2);0;21;(0,4),448,1408;conv:(0,6)=@s32;-16;,1856,32;fail:(0,6),1888,32;np:(0,2),1920,32;itct:(0,2),1952,32;ppind:(0,2),1984,32;; in cinvert.o
ld: warning: can't find atom for N_GSYM stabs cso:G(0,4) in cinvert.o
ld: warning: can't find atom for N_GSYM stabs resgn2:G(0,7)=s59364wk:(0,8)=ar(0,2);0;19;(0,4),0,1280;vt:(0,9)=ar(0,2);0;4999;(0,4),1280,320000;bi:(0,10)=ar(0,2);0;799;(0,4),321280,51200;r:(0,11)=ar(0,2);0;799;(0,4),372480,51200;ri:(0,12)=ar(0,2);0;799;(0,4),423680,51200;errno1:(0,2),474880,32;; in cinvert.o
ld: warning: can't find atom for N_GSYM stabs wk:G(0,8) in cinvert.o
ld: in cinvert.o, sectionForAddress(0xE7F0) address not in any section for architecture i386
collect2: ld returned 1 exit status
make: *** [] Error 1
ERROR: compilation failed for package ‘cts’
* removing ‘/Users/ken/R-dev/cts’
* restoring previous ‘/Users/ken/R-dev/cts’
Warning message:
In install.packages("~/Downloads/cts_1.0-11.tar.gz", .libPaths()[1],  :
  installation of package ‘/Users/ken/Downloads/cts_1.0-11.tar.gz’ had non-zero exit status

Are there any compile/link flags I should pass to install.packages(), maybe? What options are the CRAN binary build machines using?