autotools and -Wl,-whole-archive

南笙酒味 提交于 2019-12-10 21:57:05

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/22210903/autotools-and-wl-whole-archive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!