[Rd] reusing external functions across libs
Albrecht Gebhardt
albrecht.gebhardt@uni-klu.ac.at
Wed, 6 Sep 2000 10:53:44 +0200 (MET DST)
On Wed, 6 Sep 2000, Prof Brian D Ripley wrote:
> On Wed, 6 Sep 2000, Albrecht Gebhardt wrote:
>
> >
> > ... well, I found (at least) one solution:
> >
> > > dyn.load("so1.so",now=F)
> > > dyn.load("so2.so",local=F)
> > > .C("func1",as.double(c(1,2,3)),as.integer(3))
> > in func1
> > in func2
> > [1]
> > back in func1
> > [[1]]
> > [1] 2 4 6
> >
> > [[2]]
> > [1] 3
> >
> > >
> >
> > but the question remains:
> >
> > What is the best way to share common C/Fortran sources across R libraries?
> > How should I implement the above solution in the libraries? What are the
> > side effects? Is it really portable (win32?)?
>
> It is not portable. You will not even be able to make both shared
> objects on some systems, including AIX and Windows, as they need to know
> where the symbols are going to be satisfied. And those flags (especially
> local=F) do not always work (which is why this worked on OSF4, I think).
>
> The best way that I know of is to put shared code in a shared library, and
> link so?.so against that. The only potential problem is putting the
> common library somewhere it will be found at run time if it is a shared
> library/DLL, so I would use a static library unless the code was large
> (like all of LAPACK). (This is particularly a problem on Windows,
> where the rules for finding DLLs differ by Windows version.)
>
I expected something like this. Ok. Moving the functions to a static
library should not be a problem.
But I guess now I have to add ./configure scripts and Makefiles to my
libraries. In lib1 to build the static lib (and to install it somewhere
into the library installation path) and in lib2 to find this location to
link against. It's not crucial during the development stage but at least
when it comes to distribute these libraries.
Are there any guidelines to do this?
Albrecht
......................................................................
| Albrecht Gebhardt Tel.: (++43 463) 2700/832 |
| Institut fuer Mathematik Fax : (++43 463) 2700/834 |
| Universitaet Klagenfurt mailto:albrecht.gebhardt@uni-klu.ac.at |
| Villacher Str. 161 http://www-stat.uni-klu.ac.at/~agebhard |
| A-9020 Klagenfurt, Austria |
`--------------------------------------------------------------------'
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._