GNOME Bugzilla – Bug 699442
g-ir-scanner fails when no symbols used in dumper
Last modified: 2015-02-07 16:56:07 UTC
Created attachment 243022 [details] [review] Ensure libraries always link when using libtool so we can resolve their names later Simple library: == test.c == int test_foo() { return 42; } ============ == test.h == int test_foo(); ============ Scan with: $ g-ir-scanner --no-libtool --namespace=Test --nsversion=0 --library=test --output Test-0.gir --include=GObject-2.0 test.c test.h ... ERROR: can't resolve libraries to shared libraries: test The reason it fails is the scanner doesn't find any test_*_get_type() functions so the generated dumper program uses no symbols from test.c. Thus when ldd is used to find libtest.so it fails because ld didn't link the binary against libtest. The solution is to link with --no-as-needed
I have one uncertainty about the patch - not sure how this works with other linkers.
After talking to Ryan Lortie this seems to mainly be a problem on Ubuntu where the linker is set to --no-as-needed by default.
Created attachment 243071 [details] [review] Ensure libraries always link when not using libtool so we can resolve their names later Fix typo in the commit message
Review of attachment 243071 [details] [review]: "Fix scanning libraries with no GObjects and --as-needed" might be a more informative commit message. Can you also link back to this bug in the commit message? One concern: This looks likely to break the MSVC case; I guess the current discriminator is "if self._pkgconfig_msvc_flags", so add that to the conditional?
Created attachment 243075 [details] [review] Fix scanning libraries with no GObjects and linker using --as-needed
Review of attachment 243075 [details] [review]: Looks good, thanks!
Comment on attachment 243075 [details] [review] Fix scanning libraries with no GObjects and linker using --as-needed Thanks for the review!
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]