From Kurt.Hornik@ci.tuwien.ac.at  Wed Jun  9 14:53:46 1999
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Wed, 9 Jun 1999 15:53:46 +0200 (CEST)
Subject: packages with FORTRAN code
In-Reply-To: <199906091318.PAA26169@alpha.luc.ac.be>
References: <14174.23554.302077.914375@pc87.maho.magnaeu.com>
 <199906091318.PAA26169@alpha.luc.ac.be>
Message-ID: <14174.29162.922143.362849@pc87.maho.magnaeu.com>

>>>>> Jim Lindsey writes:

>> Yes, sure.  You may simply want to include $(R_HOME)/etc/Makeconf which
>> has the rule


> The following, put in my Makefile, works without the include. (I had
> the same without the final $(FLIBS) before.) Will this be OK on other
> systems? (The mva and modreg libraries have both the include and the
> following rule but without $(FLIBS)???)

>   I'm afraid that I don't understand this at all. All of my libraries
> have Fortran code. Why pick on growth? When I use $(FLIBS), it just
> links f2c into my library whereas it is already linked into R. On my
> son's computer with g77, FLIBS is defined, in etc/Makeconf, as a blank
> so that nothing occurs for him. (My toms614.c function in my rmutil
> library was obtained from f2c. It runs on my son's computer without
> f2clib linked in, except for that part of the library built into R.)

>   What is the point of all this?

The point is that there are cases when compiling FORTRAN code with g77
results in unresolved symbols at (dynload) run-time.  What exactly is
going on is not really easy to determine, and e.g. the info pages on g77
are rather vague:

	   The `libf2c' library is distributed with GNU Fortran for the
	convenience of its users, but is not part of GNU Fortran.  It
	contains the procedures needed by Fortran programs while they
	are running. 

	   For example, while code generated by `g77' is likely to do
	additions, subtractions, and multiplications "in line"--in the
	actual compiled code--it is not likely to do trigonometric
	functions this way. 

	   Instead, operations like trigonometric functions are compiled
	by the `f771' compiler (invoked by `g77' when compiling Fortran
	code) into machine code that, when run, calls on functions in
	`libf2c', so `libf2c' must be linked with almost every useful
	program having any component compiled by GNU Fortran.  (As
	mentioned above, the `g77' command takes care of all this for
	you.)

Therefore, it seems to be a good idea to always add `-lf2c' (or `-lg2c')
to FLIBS when using g77.  The most recent 0.65 configure scripts already
do that, so it would be nice if packages were cooperative by simply
using FLIBS.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


packages with FORTRAN code
Kurt Hornik