Pregunta

Is it possible to tell autotools to link one of the libraries with -Wl,-whole-archive flag?

Makefile.am

bin_PROGRAMS = pktanon 
pktanon_SOURCES = main.cpp
pktanon_DEPENDENCIES = $(lib_LIBRARIES)
pktanon_LDADD = libpktanon.a $(LDADD) 

I need to link libpktanon.a with -Wl,-whole-archive flag, also I want make to execute something like this:

g++ -o pktanon main.o -Wl,-whole-archive libpktanon.a -Wl,-no-whole-archive -l...

(as in this question)

¿Fue útil?

Solución

I ran into a similar problem here. You can do this:

pktanon_LDFLAGS = -Wl,--whole-archive,libpktanon.a,--no-whole-archive

The issue is that Libtool doesn't guarantee the order of linker flags on the actual command line it executes, so you have to force it like this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top