Date: Thu, 5 Feb 2009 15:36:32 +0300 From: pluknet <pluknet@gmail.com> To: freebsd-hackers@freebsd.org Subject: Re: linking .a lib with another library Message-ID: <a31046fc0902050436k49b3f784xd624188e2bd76ca8@mail.gmail.com> In-Reply-To: <a31046fc0902050301k44955c40lf0cd379a376ee7e5@mail.gmail.com> References: <a31046fc0902050301k44955c40lf0cd379a376ee7e5@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
2009/2/5 pluknet <pluknet@gmail.com>: > Hi. > > The problem is: > > I have a program which is statically linked to my static lib during a build. > The lib is in turn uses kvm*() calls, hence it should be linked with libkvm. > > During the build of my binaries which are linked to my libucron.a I > get the following: > > /usr/home/pluknet/svn/ucron/ksucron/crond/../lib/libucron.a(misc.o)(.text+0x6e): > In function `check_pidfile': > : undefined reference to `kvm_open' > /usr/home/pluknet/svn/ucron/ksucron/crond/../lib/libucron.a(misc.o)(.text+0x8b): > In function `check_pidfile': > : undefined reference to `kvm_getprocs' > /usr/home/pluknet/svn/ucron/ksucron/crond/../lib/libucron.a(misc.o)(.text+0xbe): > In function `check_pidfile': > : undefined reference to `kvm_getprocs' > /usr/home/pluknet/svn/ucron/ksucron/crond/../lib/libucron.a(misc.o)(.text+0x106): > In function `check_pidfile': > : undefined reference to `kvm_close' > *** Error code 1 > > Ok, if I add SHLIB_MAJOR directive in lib/Makefile (or remove any kvm* > references) then all is ok. > But the lib is used to be static. So the question is can I somehow > link two .a libraries? > e.g. libkvm.a + libucron.a + my binaries. > Ok, I finally got it: gcc crond/crond.o lib/libucron.a /usr/lib/libkvm.a -L/usr/local/lib/mysql -lmysqlclient or in BNF (bmake normal form): LDADD+= -lmysqlclient -lucron ${LIBKVM} $ ldd crond/crond crond/crond: libmysqlclient.so.14 => /usr/local/lib/mysql/libmysqlclient.so.14 (0x28080000) libc.so.6 => /lib/libc.so.6 (0x280d5000) libcrypt.so.3 => /lib/libcrypt.so.3 (0x281ba000) libm.so.4 => /lib/libm.so.4 (0x281d2000) libz.so.3 => /lib/libz.so.3 (0x281e8000) The only drawback is that I had to add that to crond/Makefile, not to lib/Makefile. crond knows nothing about kvm calls and now it has to (and lib does vice versa). -- wbr, pluknet
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a31046fc0902050436k49b3f784xd624188e2bd76ca8>