bstpierre
bstpierre

Reputation: 31176

Repeating libs on libtool command line

I'm using automake, and getting a libtool invocation like this:

/bin/sh ../libtool --tag=CC --mode=link gcc -o test_foo test_foo.o -lA -lB -lC -lA -lB -lC

Note that the libraries (which are beyond my control) have circular dependencies that require them to be mentioned more than once. Unfortunately it seems that libtool folds multiple requests for libraries into a single request, and it runs:

gcc -o test_foo test_foo.o -lA -lB -lC

Note that the second pass over the libs is gone; I get a bunch of linker errors. When I manually run that gcc command line with the extra -l flags, it works.

How can I make libtool pass all the libs I've requested to gcc?

Upvotes: 4

Views: 850

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

How can I make libtool pass all the libs I've requested to gcc?

I don't know how to do that. Note however, that if you are on a system that uses GNU-ld (or gold), you can achieve the same result with

-Wl,--start-group -lA -lB -lC -Wl,--end-group

Perhaps libtool will leave these unmolested? Alas, libtool 2.2.6b moves -Wl,--end-group before all the libraries ;-(

This gross hack does it:

-Wl,--start-group,-lA,-lB,-lC,--end-group

(I find that libtool is wrong 99% of the time and try to avoid it like a plague.)

Upvotes: 6

Related Questions