如何强制测试程序链接到libtool构建的静态库
我有一个由自动工具管理的库。我在 Makefile.am
中有以下行,以及其他必要的配置
lib_LTLIBRARIES = libstuff.la
我的项目还构建了一个程序来运行一些测试套件。该程序的配置如下:
noinst_PROGRAMS = runtests
runtests_SOURCES = test/stuff.c stuff.h
runtests_LDADD = libstuff.la
但是,该程序始终链接到libstuff.la
的动态版本,这使某些情况变得复杂(例如,使用gdb
进行调试)。如何强制程序链接到 libstuff.a
而不是 libstuff.so
或等效的动态库?
I have a library managed by autotools. I have the following line in the Makefile.am
, as well as other necessary configurations
lib_LTLIBRARIES = libstuff.la
My project also builds a program to run some test suites. This program is configured as follows:
noinst_PROGRAMS = runtests
runtests_SOURCES = test/stuff.c stuff.h
runtests_LDADD = libstuff.la
However, the program is always linked to the dynamic version of libstuff.la
, which complicates some situations (for example, debugging with gdb
). How could I force the program to be linked against libstuff.a
instead of libstuff.so
or equivalent dynamic library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的方法是将
-static
标志添加到LDFLAGS
变量中。对于所有目标:
AM_LDFLAGS = -static
或者专门针对测试程序:
runtests_LDFLAGS = -static
The right way to do this is to add the
-static
flag to anLDFLAGS
variable.For all targets:
AM_LDFLAGS = -static
Or specifically for the test program:
runtests_LDFLAGS = -static