: Libtool convenience library to unit test private functions
Only the public API of a library is exported, so when a program is dynamically linked to the DSO (Dynamic Shared Object), it can only use the public functions.
So how do you unit test the private classes of your library?
There is a simple solution, having a Libtool convenience library that
contains the whole code of the library, but without an -export
linker flag, so that all functions can still be accessed. You then link that
*.la file to your unit tests and also to the real library where you add the
appropriate -export flag.
You can see that in action in GtkSourceView and gspell. For example in gspell:
When you run make in verbose mode with make V=1,
you see that the libtool commands statically link the convenience static
library (a file with the *.a extension) into the unit test programs and into
the DSO.
That way the *.c files are compiled only once, and adding a unit test to the
testsuite/Makefile.am is straightforward.
Edit: update links (in 2026).