--as-needed and undefined non-weak symbols
Rex Dieter
rdieter at math.unl.edu
Thu Oct 26 14:52:42 UTC 2006
Ville Skyttä wrote:
> I'm wondering if I've stumbled upon a bug in ld's --as-needed or
> something I was not aware of, here's an example, foo.c:
>
> extern void gtk_main();
> int main() {
> gtk_main();
> }
>
> Now, libgtk (as of FC5) contains lots of undefined gdk_* symbols, so
Yeah, bad. Fixed that for gtk+ in Extras/fc6. (:
> trying "gcc -lgtk foo.c" on the above fails as expected, and "gcc -lgdk
> -lgtk foo.c" succeeds, again as expected. However, to my surprise, "gcc
> -Wl,--as-needed -lgdk -lgtk foo.c" fails:
Try
gcc -Wl,--as-needed foo.c -lgtk -lgdk
or even better:
gcc -Wl,--as-needed foo.c `pkg-config --libs gtk+`
instead.
-- Rex
More information about the fedora-devel-list
mailing list