[Rd] reusing external functions across libs
Saikat DebRoy
saikat@stat.wisc.edu
06 Sep 2000 08:44:00 -0500
--=-=-=
>>>>> "Albrecht" == Albrecht Gebhardt <albrecht.gebhardt@uni-klu.ac.at> writes:
Albrecht> But I guess now I have to add ./configure scripts and
Albrecht> Makefiles to my libraries. In lib1 to build the static lib
Albrecht> (and to install it somewhere into the library installation
Albrecht> path) and in lib2 to find this location to link
Albrecht> against. It's not crucial during the development stage but
Albrecht> at least when it comes to distribute these libraries.
Albrecht> Are there any guidelines to do this?
There is some information in the R Extensions manual. See the section
on congigure and cleanup.
We have faced a somewhat similar situation in a few projects. From our
experience the following scheme (due to Duncan Temple Lang) may
work. Note that we have tested this only on a few platforms. In
particular this (as it stands) possibly would not work on Windows.
Suppose you have two packages, package1 and package2. You want the
shared object file in package2 to depend on that of package1.
Install package1 as usual with R INSTALL package1. In package2, add a
configure script and a src/Makevars.in file. You may also want to add
a cleanup script.
Here are some example scripts. Remember to replace package1 and
package2 with appropriate names. You have to run autoconf to geneerate
the configure script for configure.in. Alos, these are modified
versions of existing scripts and I have not tested these modified versions.
Saikat
--
Department of Statistics Email: saikat@stat.wisc.edu
University of Wisconsin - Madison Phone: (608) 263 5948
1210 West Dayton Street Fax: (608) 262 0032
Madison, WI 53706-1685
--=-=-=
Content-Type: multipart/mixed; boundary="==-=-="
--==-=-=
Content-Disposition: attachment
Content-Description: Makevars.in
# package2/src/Makevars.in
# link package2.so against the package1.so. This is done by creating a
# libpackage1.so in the top level directory of package2.
PKG_LIBS=-L@TOP@ -lpackage1
--==-=-=
Content-Disposition: attachment
Content-Description: configure.in
# package2/configure.in
AC_INIT(src/package2.c) # replace with appropriate source file in src
# Find the current directory - the toplevel directory for package2
TOP=`pwd`
AC_SUBST(TOP)
# find installation path for package1
# package1 has to be installed during installing package2
if test -z "${R_HOME}" ; then
R_HOME=`R RHOME`
fi
if test -z "${R_HOME}" ; then
echo "Cannot find the R distribution!"
exit 1
fi
echo 'cat(paste("PACKAGE1_LIBS=",system.file("libs", pkg="packag1"),"\n",sep=""), file="./Package1Libs")' | $R_HOME/bin/R --vanilla
chmod +x Package1Libs
. ./Package1Libs
if test -z "${PACKAGE1_LIBS}" ; then
echo "Cannot find the package1 library for R. Please install it,"
echo "or set the environment R_LIBS so that it can be found in an R session."
exit 1;
fi
echo "Computed PACKAGE1_LIBS: ${PACKAGE1_LIBS}"
AC_OUTPUT(src/Makevars)
if test ! -f libpackage1.so ; then
ln -s $PACKAGE1_LIBS/package1.so libpackage1.so
fi
--==-=-=--
--=-=-=
--=-=-=--
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._