static vs. dynamic

Troy A. Griffitts junkmail at
Mon Sep 3 18:00:04 PDT 2007

I'm a little fuzzy on how to build a .pc file that works correctly for 
both dynamic and static builds.

We have an engine that can be built to install either static or dynamic 
or both libraries.  Clients of our engine use pkg-config to get cflags 
and ldflags information.

Everything seems to work great for any one of the scenarios, but I don't 
understand how to build a .pc file to work correctly for clients 
regardless of what is installed (static, dynamic, or both).

The dynamic library gets its dependency info from the .la file, so the 
.pc file Libs entry is short.  The static library needs all the 
dependencies listed in the Libs.private, as I understand.

A typical client makefile contains something like this:

         g++ -g `pkg-config --cflags sword` $< -o $@ `pkg-config --libs 

If the shared sword libs are installed, great, no problems.
If the both are installed, the shared are used, no problems.
If only the static are installed, we get tons of link errors.
If I change the line to:

g++ -g `pkg-config --static --cflags sword` $< -o $@ `pkg-config 
--static --libs sword`

things work, no problems.

It's this last scenario I'm concerned about.  The user shouldn't have to 
know that only the static libs for sword have been installed.  They 
aren't choosing static over dynamic; they just want to link to whatever 
is required for linking against the sword libraries.  Which is where 
pkg-config come in and does a great job; I usually don't need to know 
all my compile or link options.  But in this case the user does need to 
know about 1 particular link option, in a sense.

Maybe I've just missed something, but if only static libs are available, 
shouldn't pkg-config use Libs.private?

	Thanks for any insights,

		-Troy A. Griffitts

Here are the specifics:
dependency_libs=' -licui18n -licuuc -licudata -lpthread -licuio
-L/usr/kerberos/lib64 -lcurl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err
-lresolv -ldl -lidn -lssl -lcrypto -L/usr/lib64 -lz -lclucene'



Description: Biblical Text Engine
Version: 1.5.9
Libs: -L${libdir} -lsword
Libs.private: -L${libdir} -lsword -lz -L/usr/kerberos/lib64 -lcurl
-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv -ldl -lidn -lssl
-lcrypto -lz   -L/usr/lib64 -lclucene -licui18n -licuuc -licudata
-lpthread -lm   -licuio
Cflags: -I${includedir}/sword

More information about the pkg-config mailing list