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/ (custom.conf, perhaps) and add the line:


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:


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.


  1. You might want to add /usr/local/.. to the PATH and PKG_CONFIG_PATH in /etc/bash.bashrc (or perhaps /etc/skel/,bashrc) if the system is being used by more than one person (and you want other people to be able to use the applications you’ve built).

Comments are closed.