Category Archives: Uncategorized

Building programs and libraries from source on Fedora

Packages built from source use the prefix /usr/local by default which is not set up in the in the Fedora system and library paths. The majority of the documentation on the net seems to suggest Fedora users just pass –prefix=/usr to configure scripts but this can obviously cause problems in the long term (writing over the distributions provided binaries) and I decided it would also be much more useful to me to investigate what needs changing so that applications and libraries built in the default prefix will work.

If you are only building programs using the Fedora provided -devel packages you just need to modify your PATH so that /usr/local/bin is in there. In your .profile, .bashrc, whatever add:

export PATH=$PATH:/usr/local/bin

Easy enough and very familiar!

It gets slightly more complex if you are building libraries. First off you will need to configure the dynamic linker to look in the default libs prefix, create a new file in /etc/ld.so.conf.d/ (custom.conf, perhaps) and add the line:

/usr/local/lib

Every time you install a new library you will need to run ldconfig to regenerate the dynamic bindings cache, you’ll need to run this as root:

/sbin/ldconfig

Finally you’ll need to tell pkgconfig to also look in your new library directory:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Of course, none of this is particularly revelationary but I enjoyed the opportunity to learn more about the tools and thought it was probably worth sharing.