When should I install a library to lib/ , and when to, say, lib/x86_64-linux-gnu?

1.7k views Asked by At

I've compiled a static C or C++ library, obtaining a libfoo.a. I want to decide where it should be installed after having been built. Never mind what build/installation mechanism I'm using - this is a question of principle.

Now, on the installation root (which may be /usr, or /usr/local etc.) there are two subdirectories of interest: lib/, and a directory whose name depends on the processor architecture, the kind of kernel and the kind of userland, e.g. x86_64, Linux and GNU, for lib/x86_64-linux-gnu.

I've compiled the library with x86_64 object code, and using a Linux version of glibc; but then - all libraries are compiled that way, basically. So, how do I decide whether my library should go into just lib/, or rather lib/x86_64-linux-gnu?

Note: If I were on a non-Debian distribution, the dilemma would probably have been between lib/ and lib64/ - which is still basically the same dilemma.

1

There are 1 answers

2
caconym On

The lib/x86_64-linux-gnu naming scheme is specific to Debian-based distros and is used to support multiarch. Many other distros are still using the Filesystem Hierarchy Standard, which uses /lib, /lib32, /lib64, etc. instead of the lib/x86_64-linux-gnu convention.

While there has been some work to incorporate the Debian naming scheme into the standard, it hasn't really been resolved yet. So it's probably better to follow the convention of the distribution you're packaging for.

In this case, it seems to mean putting the shared library into the corresponding architecture's subdirectory according to the Debian wiki.