[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Installing convenience libraries
From: |
Akim Demaille |
Subject: |
Installing convenience libraries |
Date: |
Fri, 29 Sep 2006 10:41:36 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
[Please keep me in CC.]
Hi,
I'm trying to build a convenience library, install it, build another
convenience library on top of it (and again install it), and finally
link an executable using the latter library.
I thought I could do that using Libtool static libraries with
extension .la, but it seems I can't do that. It works well with
.o/.a, but with .lo/.la, it fails without an explicit explanation:
| + libtool --tag=CC --mode=compile gcc -static foo.c -c -o foo.lo
| mkdir .libs
| gcc foo.c -c -fPIC -DPIC -o .libs/foo.o
| gcc foo.c -c -o foo.o >/dev/null 2>&1
| + libtool --tag=CC --mode=link gcc -static foo.lo -o libfoo.la
| ar cru .libs/libfoo.a foo.o
| ranlib .libs/libfoo.a
| creating libfoo.la
| (cd .libs && rm -f libfoo.la && ln -s ../libfoo.la libfoo.la)
| + libtool --tag=CC --mode=install install -c libfoo.la
/tmp/test-libtool.sh.tmp/lib/libfoo.la
| install -c .libs/libfoo.lai /tmp/test-libtool.sh.tmp/lib/libfoo.la
| install: cannot stat `.libs/libfoo.lai': No such file or directory
Am I trying to do something silly? This is
ltmain.sh (GNU libtool) 1.5.22 Debian 1.5.22-4 (1.1220.2.365 2005/12/18
22:14:06)
If you want to try, use the attached script. Without argument it uses
.o/.a, with -l it uses .lo/.la. I'd like to stick to Libtool
libraries because eventually we will probably move to using dynamic
libraries (i.e., the first library libfoo would remain a convenience
library, which should be later integrated into libbar so that the
latter is really self-contained. Not clear this is doable...).
Any help is appreciated!
#! /bin/sh
set -ex
case $1 in
-l) ext=l;;
'') ext=;;
*) exit 1
esac
libtool='libtool --tag=CC'
tmp=/tmp/$(basename $0).tmp
rm -rf $tmp
mkdir $tmp
cd $tmp
mkdir lib
make_object ()
{
base=$1
cat >$base.c <<EOF
int
$base ()
{
return 42;
}
EOF
$libtool --mode=compile gcc -static $base.c -c -o $base.${ext}o
}
make_lib ()
{
make_object $1
$libtool --mode=link gcc -static $base.${ext}o -o lib$base.${ext}a
$libtool --mode=install install -c lib$base.${ext}a $tmp/lib/lib$base.${ext}a
}
make_lib foo <<EOF
int
$base ()
{
return 42;
}
EOF
make_lib bar <<EOF
extern int foo ();
int
$base ()
{
return foo ();
}
EOF
make_object main <<EOF
extern int bar ();
int
main ()
{
return bar ();
}
EOF
$libtool --mode=link gcc main.${ext}o -o main $tmp/lib/libbar.${ext}a
if ./main; then
exit 1
else
echo $?
fi
- Installing convenience libraries,
Akim Demaille <=