2

Basically, I downloaded an SDK for C/C++, and I have several .so and .a files. There is no install script with the SDK. It simply contains the headers and the .so and .a files. I don't really know where to put these files.

Typically, if I download some SDK, there is an install script that does this for me. I haven't had to do this manually. Where do I put these files?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Ralff
  • 401
  • 2
  • 5
  • 15

2 Answers2

2

In Unix and Linux the following conventions are normally observed for the use of the directories referred to:-

  • /usr: - Contents are not system-critical

  • /usr/bin - Root path of executables installed by the vendor/distro or with the vendor/distro's package manager

  • /usr/lib - Root path of libraries installed by the vendor/distro or with the vendor/distro's package manager

  • /usr/include - Root path of header files installed by the vendor/distro or with the vendor/distro's package manager

  • /usr/local/bin - Root path of executables installed by a system user with root privelege (You) but not with vendor/distro's package manager

  • /usr/local/lib - Root path of libraries installed by You but not with vendor/distro's package manager

  • /usr/local/include - Root path of header files installed by You but not with vendor/distro's package manager

For the stablity of your system it is important that you install or remove files in usr/{bin|lib|include} only with the vendor/distro's package manager, which you can trust to understand the interdependencies of packages (by version) and not to mess the system up.

On the other hand the package manager will not install files beneath usr/local and You may do so, with root privelege. So usr/local/{bin|lib|include} are suitable places to install executables|libaries|header files that you build from source or acquire ready-made but not packaged for your package manager.

These locations are specifically suitable for installing files to be used in building C or C++ software because:-

usr/local/bin is a default search path for executables.

usr/local/include is a default compiler search path for header files, so if your code contains, e.g.

#include <foo/bar.h>

and you have installed usr/local/include/foo/bar.h, then you don't need to pass the compiler any -I option to let it find that header.

usr/local/lib is a default linker search path for libraries, so if your program needs to be linked, e.g. with libfoo.a and you have installed usr/local/lib/libfoo.a, then you then you don't need to pass the linker any -L option to let it find that library: -lfoo will suffice.

However, if you place a shared library, e.g. libfoo.so in usr/local/lib (or anywhere, for that matter), the runtime loader will fail to find it at runtime unless you have first refreshed its shared library cache. You will need to run:

ldconfig /usr/local/lib

after putting any new shared libraries there.

Don't forget that any binaries you install, without access to source code, that do not come packaged in your vendor/distro's official repositories stand an elevated chance of containing malware.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
0

It doesn't matter really - you will have to pass lib path to compiler anyway. If you put them in application main dir (where the source is and where do you run make) you wouldn't have to put full path. Otherwise you will just put absolute or relative path.

Anty
  • 1,486
  • 1
  • 9
  • 12