Statically link bundled libraries

Sébastien Wilmet swilmet at gnome.org
Thu Jun 23 09:19:34 UTC 2016


On Wed, Jun 22, 2016 at 11:17:56AM -0700, Dan Nicholson wrote:
> It's not at all straightforward to do static linking, but here's how
> I'd try to do assuming autotools for everything.
> 
> Configure libraries with --enable-static --disable-shared. Then you'll
> only get the static libraries installed and the linker can't even try
> to do dynamic linking. In order to pull in everything needed, you'd
> then want to use the pkg-config --static option so that it returns the
> entire list of libraries in Requires.private and Libs.private. You
> should probably be able to accomplish this by setting the environment
> variable PKG_CONFIG="pkg-config --static". That assumes that the
> environment variable is respected everywhere, but the pkg-config
> autoconf macros do that.

I didn't know that pkg-config supports static linking. That's good to
know. And with the env variable it's maybe possible to do static linking
without modifying the application build system.

> That's not full static linking (you'd need to tell the compiler/linker
> you want that), but I think it would accomplish the case you're
> thinking about where you only want the bundled libraries to be
> statically linked and don't need to provide a truly static binary.

Yes, just for the libraries bundled with the application. For the
libraries present in the runtime, still do dynamic linking.

--
Sébastien



More information about the xdg-app mailing list