
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote:
I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix:
Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors.
--- tests/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index dfd9e34..1b5f287 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ LDADDS = \ $(SASL_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../src/libvirt.la \ ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS)
Not sure I understand this one.
LIBVIRT is defined as:
LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o)
Doesn't that work in the static case too?
Unfortunately not, since the wildcard doesn't match anything: $ ls -1 ../src/.libs/libvirt* ../src/.libs/libvirt.a ../src/.libs/libvirt.la@ ../src/.libs/libvirt.lai If you want to try to reproduce it yourself, do this: ./configure --disable-shared && make Without my patch, I get results like this on rawhide: ... xmlrpc.o: In function `xmlRpcValueMarshal': /home/meyering/w/co/libvirt/tests/../src/xmlrpc.c:363: undefined reference to `virBufferStrcat' collect2: ld returned 1 exit status make[2]: *** [xmlrpctest] Error 1 xml2sexprtest.o: In function `testCompareFiles': /home/meyering/w/co/libvirt/tests/xml2sexprtest.c:42: undefined reference to `virDomainParseXMLDesc' collect2: ld returned 1 exit status make[2]: *** [xml2sexprtest] Error 1 reconnect.o: In function `main': /home/meyering/w/co/libvirt/tests/reconnect.c:20: undefined reference to `virSetErrorFunc' /home/meyering/w/co/libvirt/tests/reconnect.c:22: undefined reference to `virConnectOpen' /home/meyering/w/co/libvirt/tests/reconnect.c:31: undefined reference to `virDomainLookupByID' /home/meyering/w/co/libvirt/tests/reconnect.c:36: undefined reference to `virDomainFree' /home/meyering/w/co/libvirt/tests/reconnect.c:37: undefined reference to `virConnectClose' /home/meyering/w/co/libvirt/tests/reconnect.c:41: undefined reference to `virConnectOpen' /home/meyering/w/co/libvirt/tests/reconnect.c:46: undefined reference to `virDomainLookupByID' /home/meyering/w/co/libvirt/tests/reconnect.c:39: undefined reference to `virConnectOpenReadOnly' /home/meyering/w/co/libvirt/tests/reconnect.c:25: undefined reference to `virConnectOpenReadOnly' /home/meyering/w/co/libvirt/tests/reconnect.c:51: undefined reference to `virDomainFree' /home/meyering/w/co/libvirt/tests/reconnect.c:52: undefined reference to `virConnectClose' collect2: ld returned 1 exit status make[2]: *** [reconnect] Error 1 make[2]: Leaving directory `/home/meyering/w/co/libvirt/tests' make[1]: *** [check-recursive] Error 1 make[1]: Leaving directory `/home/meyering/w/co/libvirt/tests' make: *** [check-recursive] Error 1 I'll see what happens with profiling.