undefined reference to `rsvg_rust_*' when statically linking
I'm trying to compile a statically linked node-canvas which uses librsvg. It works fine with version 2.40.20 (The last version not using Rust) but fails with later version. With current version 2.45.6 it complains about undefined references which all starts with rsvg_rust_
.
I can also reproduce it with a small test program on a system where librsvg and all its dependencies are present as static libraries (Manually compiled). Librsvg is compiled like this:
./configure \
--prefix=/usr/local \
--enable-shared \
--enable-static \
--with-pic \
--enable-introspection=no \
--disable-tools \
make install
Because of #159 (closed) I do not disable the shared library but I remove it after installation so it isn't accidentally used later.
This is the small test program:
#include <librsvg/rsvg.h>
int main() {
RsvgHandle *handle = rsvg_handle_new();
}
And that's how I compile the test program:
gcc -static $(pkg-config librsvg-2.0 --static --cflags) -o test test.c $(pkg-config librsvg-2.0 pango libxml-2.0 pangocairo libcroco-0.6 --static --libs)
And it complains with the following error messages:
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_write':
/tmp/librsvg/librsvg/rsvg-handle.c:555: undefined reference to `rsvg_rust_handle_write'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_set_dpi_x_y':
/tmp/librsvg/librsvg/rsvg-handle.c:945: undefined reference to `rsvg_rust_handle_set_dpi_x'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_type':
/tmp/librsvg/librsvg/rsvg-handle.c:355: undefined reference to `rsvg_rust_handle_get_type'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_new_from_data':
/tmp/librsvg/librsvg/rsvg-handle.c:423: undefined reference to `rsvg_rust_handle_new_from_data'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_new_from_file':
/tmp/librsvg/librsvg/rsvg-handle.c:442: undefined reference to `rsvg_rust_handle_new_from_file'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_new_with_flags':
/tmp/librsvg/librsvg/rsvg-handle.c:458: undefined reference to `rsvg_rust_handle_new_with_flags'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_new_from_gfile_sync':
/tmp/librsvg/librsvg/rsvg-handle.c:489: undefined reference to `rsvg_rust_handle_new_from_gfile_sync'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_new_from_stream_sync':
/tmp/librsvg/librsvg/rsvg-handle.c:523: undefined reference to `rsvg_rust_handle_new_from_stream_sync'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_close':
/tmp/librsvg/librsvg/rsvg-handle.c:579: undefined reference to `rsvg_rust_handle_close'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_read_stream_sync':
/tmp/librsvg/librsvg/rsvg-handle.c:612: undefined reference to `rsvg_rust_handle_read_stream_sync'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_set_base_uri':
/tmp/librsvg/librsvg/rsvg-handle.c:634: undefined reference to `rsvg_rust_handle_set_base_url'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_set_base_gfile':
/tmp/librsvg/librsvg/rsvg-handle.c:655: undefined reference to `rsvg_rust_handle_set_base_gfile'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_base_uri':
/tmp/librsvg/librsvg/rsvg-handle.c:672: undefined reference to `rsvg_rust_handle_get_base_url'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_render_cairo_sub':
/tmp/librsvg/librsvg/rsvg-handle.c:754: undefined reference to `rsvg_rust_handle_render_cairo_sub'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_dimensions':
/tmp/librsvg/librsvg/rsvg-handle.c:791: undefined reference to `rsvg_rust_handle_get_dimensions'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_dimensions_sub':
/tmp/librsvg/librsvg/rsvg-handle.c:816: undefined reference to `rsvg_rust_handle_get_dimensions_sub'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_position_sub':
/tmp/librsvg/librsvg/rsvg-handle.c:841: undefined reference to `rsvg_rust_handle_get_position_sub'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_has_sub':
/tmp/librsvg/librsvg/rsvg-handle.c:860: undefined reference to `rsvg_rust_handle_has_sub'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_pixbuf_sub':
/tmp/librsvg/librsvg/rsvg-handle.c:890: undefined reference to `rsvg_rust_handle_get_pixbuf_sub'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_set_dpi_x_y':
/tmp/librsvg/librsvg/rsvg-handle.c:946: undefined reference to `rsvg_rust_handle_set_dpi_y'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_set_size_callback':
/tmp/librsvg/librsvg/rsvg-handle.c:1014: undefined reference to `rsvg_rust_handle_set_size_callback'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_intrinsic_dimensions':
/tmp/librsvg/librsvg/rsvg-handle.c:1070: undefined reference to `rsvg_rust_handle_get_intrinsic_dimensions'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_get_geometry_for_element':
/tmp/librsvg/librsvg/rsvg-handle.c:1127: undefined reference to `rsvg_rust_handle_get_geometry_for_element'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_internal_set_testing':
/tmp/librsvg/librsvg/rsvg-handle.c:1148: undefined reference to `rsvg_rust_handle_set_testing'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_error_get_type':
/tmp/librsvg/librsvg/rsvg-handle.c:1154: undefined reference to `rsvg_rust_error_get_type'
/usr/bin/ld: /usr/local/lib/librsvg-2.a(2_la-rsvg-handle.o): in function `rsvg_handle_flags_get_type':
/tmp/librsvg/librsvg/rsvg-handle.c:1160: undefined reference to `rsvg_rust_handle_flags_get_type'
collect2: error: ld returned 1 exit status
When I do the same thing with librsvg 2.40.20 then the program compiles without error messages.
Interesting that only the rsvg_rust_*
symbols are missing. Any idea what's going wrong here?