[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Generation of static libraries is broken for a Rust sub-library (librsvg

From: Federico Mena Quintero
Subject: Generation of static libraries is broken for a Rust sub-library (librsvg)?
Date: Tue, 06 Feb 2018 18:38:01 -0600

Hi, everyone,

I'm trying to figure out why librsvg's build setup is broken for static
libraries.  The automake/libtool machinery works fine to build, but the resulting librsvg.a is broken.

Librsvg gets built from a bunch of .o files from C, and a
librsvg_internals.a library built by Rust/Cargo.  Rust properly
compiles this internals library with PIC.

After the .o files and the librsvg_internals.a are built, we use
libtool in the usual fashion:


address@hidden@_la_LIBADD = \
        $(LIBRSVG_LIBS)         \
        $(LIBM)                 \

That is, LIBADD contains the librsvg_internals.a.

The resulting is built just fine.  However, the static
librsvg.a is broken.  For example, this is the output of "ar -t":

$ cd ~/src/librsvg
$ ar -t .libs/librsvg-2.a
librsvg_internals.a                   <- this is the Rust sub-library
[... a bunch of other .o files here ...]

While I don't know all the details of how .a files are made from
libtool, it sounds like that librsvg_internals.a should really be
exploded into the individual .o files, and *those* put into the final
librsvg.a library.

Indeed if I have a tiny program foo.c:

#include <librsvg/rsvg.h>
int main(){
  RsvgHandle *svg = rsvg_handle_new_from_data (NULL, 0, NULL);

and build it like this:

$ gcc -o foo foo.c `pkg-config --cflags librsvg-2.0` librsvg-2.a `pkg-
config --libs cairo-fc gobject-2.0 gio-2.0 libxml-2.0` -lm

it doesn't work; it gives me this output:

librsvg-2.a(librsvg_2_la-rsvg-base.o): In function `add_node_to_handle':
/home/federico/src/librsvg-latest/rsvg-base.c:207: undefined reference to 
librsvg-2.a(librsvg_2_la-rsvg-base.o): In function `node_set_atts':
/home/federico/src/librsvg-latest/rsvg-base.c:396: undefined reference to 
/home/federico/src/librsvg-latest/rsvg-base.c:402: undefined reference to 
[... tons more of undefined symbols ...]

Those symbols are indeed in the librsvg_internals.a sub-library.

How can I make libtool create the toplevel librsvg.a correctly, out of
a bunch of .o files and a librsvg_internals.a library that is already

(This also breaks --disable-shared for the configure script.)

Any suggestions are appreciated.

(For reference, this is mentioned in both (Linux) and (MacOS)).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]