How to force a test program to bind to a static library created by libtool

I have a library managed by autotools. I have the following line in Makefile.am , as well as other necessary configurations

 lib_LTLIBRARIES = libstuff.la 

My project also creates 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 associated with the dynamic version of libstuff.la , which complicates some situations (for example, debugging with gdb ). How can I get a program to link to libstuff.a instead of libstuff.so or the equivalent dynamic library?

+4
source share
1 answer

The correct way to do this is to add the -static flag to the LDFLAGS variable. For all purposes: AM_LDFLAGS = -static

Or specifically for the test program: runtests_LDFLAGS = -static

+8
source

Source: https://habr.com/ru/post/1387490/


All Articles