Question

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?

Was it helpful?

Solution

The right way to do this is to add the -static flag to an LDFLAGS variable. For all targets: AM_LDFLAGS = -static

Or specifically for the test program: runtests_LDFLAGS = -static

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top