Skip to content

R Package compilation problem with Fortran

5 messages · Brian Beckage, Simon Urbanek, Don MacQueen

#
Hello,

I've tried to load a number of packages that require a Fortran 
compiler such as BMA and Hmisc, but I get the following error:

* Installing *source* package 'Hmisc' ...
** libs
g77   -fno-common  -g -O2 -c cidxcn.f -o cidxcn.o
make: g77: Command not found
make: *** [cidxcn.o] Error 127
ERROR: compilation failed for package 'Hmisc'


But I appear to have a Fortran compiler installed:

'which g77' yields '/sw/bin/g77'
Reading specs from /sw/lib/gcc/powerpc-apple-darwin7.5.0/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/sw 
--enable-languages=f77 --infodir=/share/info --libexecdir=/lib 
--disable-shared
Thread model: posix
gcc version 3.4.1

'echo $PATH' yields:
/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/brianbeckage:/usr/X11R6/bin:.:/Users/brianbeckage/bin:/usr/local/bin

So g77 should be in the search path.

Any suggestions would be greatly appreciated.  I'm running R 2.1.0 
Patched under OSX 10.3.9.

Thanks,
Brian
#
Brian,
On Jun 10, 2005, at 12:11 AM, Brian Beckage wrote:

            
How did attempt to compile the package? This is clearly an issue with  
setting your PATH correctly. Running R CMD INSTALL (or R itself) in  
the same shell that has the PATH you describe should work. But I  
suspect that's not what you're doing ... therefore it's important to  
know how exactly you try to install it ...

Cheers,
Simon
#
I typically use R from within X11 but when installing packages I 
typically used the Aqua GUI...

So from within the GUI...I select 'Packages & Data' --> 'Package 
Installer'  and after selecting the Hmisc package, I then click on 
'Install Selected'.  Then I received the error that g77 is not found.

In addition, from within the R console, typing system('which g77') 
yields '/sw/bin/g77'
I have not used R CMD INSTALL before.  So I downloaded the package 
source onto my Desktop, unzipped it, and then typed:  R CMD INSTALL 
/Users/brianbeckage/Desktop/Hmisc

* Installing *source* package 'Hmisc' ...
** libs
g77   -fno-common  -g -O2 -c cidxcn.f -o cidxcn.o
g77   -fno-common  -g -O2 -c cidxcp.f -o cidxcp.o
g77   -fno-common  -g -O2 -c hoeffd.f -o hoeffd.o
g77   -fno-common  -g -O2 -c jacklins.f -o jacklins.o
g77   -fno-common  -g -O2 -c largrec.f -o largrec.o
gcc-3.3 -no-cpp-precomp 
-I/Library/Frameworks/R.framework/Resources/include 
-I/usr/local/include   -fno-common  -g -O2 -c ranksort.c -o ranksort.o
g77   -fno-common  -g -O2 -c rcorr.f -o rcorr.o
g77   -fno-common  -g -O2 -c wclosest.f -o wclosest.o
gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/local/lib 
-o Hmisc.so cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o 
ranksort.o rcorr.o wclosest.o 
-L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 -lg2c -lSystem 
-lcc_dynamic -framework R
ld: warning -L: directory name 
(/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2) does not exist
ld: can't locate file for: -lg2c
make: *** [Hmisc.so] Error 1
ERROR: compilation failed for package 'Hmisc'
** Removing 
'/Library/Frameworks/R.framework/Versions/2.1.0/Resources/library/Hmisc'
** Restoring previous 
'/Library/Frameworks/R.framework/Versions/2.1.0/Resources/library/Hmisc'

Any ideas?

Thanks again for your help.
Brian
#
I solved this problem by installing a newer version of the fortran 
(g77 3.4) compiler from hpc.sourceforge.net into usr/local.

Best,
Brian

  
    
#
My perspective is...

(1) If you build R from sources, and /sw (fink) is present on your 
system at the time you configure R, then R knows (internally, so to 
speak) about /sw, and will later on include it among the places it 
looks for things when you install packages.

(2) The binary version of R for OS X that you downloaded from CRAN 
was built without any dependencies on fink, so it does not 
(internally, so to speak) know about /sw, and does not look there for 
things. This is a good thing, because many, if not most, users of R 
who install the binary will not want to deal with add-on systems like 
fink. The developers/maintainers of R for OS X do not want to impose 
a requirement for fink on R uses, and this is appropriate.

My suggestion is to go to the help pages for the OS X version of R 
(the links are at the bottom of the download page, where it says "You 
may also want to read the R FAQ and R for Mac OS X FAQ or consult the 
developer page of R for Mac OS X."). Follow the instructions there to 
obtain a fortran that installs in /usr/local/bin. For example, on my 
system:

[153]% which g77
/usr/local/bin/g77

If you have g77 there, I am reasonably confident your version of R 
will find it when installing packages.

-Don
At 12:11 AM -0400 6/10/05, Brian Beckage wrote: