Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subfolders in /usr/local/lib?

I'm developing a simple C shared library for my university using Cmake. At the moment I'm developing the install procedure of my *.so and my .*h files.

Where should I put the so and the header files when the user runs the famous sudo make install? From what I understand:

  1. I shouldn't put them in /usr/lib and /usr/include since those folders are reserved for distribution packages;
  2. I shouldn't put them in /lib and /include since those folders are reserved for OS boot packages;

That leaves me with usr/local/lib and /usr/local/include. However I can't decide whether or not I should put my files in a subfolder:

  1. Putting the files directly inside usr/local/lib and /usr/local/include will make them directly available in the system but they will remain unorganized with all the other files in the folders. More disturbing fact is that if someone installs another shared library whose header has the same name of mine, unknown behaviours may happen;
  2. Putting the files in a subfolder (/usr/local/lib/myAwesomeProject/ and /usr/local/include/myAwesomeProject) will avoid the behaviours above, but will prevent the system to automatically detect my libraries (from what I understand the system automatically looks for include and library only in specific directories non-recursively): so if the system looks into /usr/local/include, my includes won't be found because of the subfolder!

To help you, here's my system:

  • OS system: Ubuntu 16.4 (64 bit virtualized on Windows 10 64-bit);
  • CPU (not that I think is useful): Intel® Core™ i5-3230M CPU @ 2.60GHz × 2;

Thanks for any kind reply!

like image 310
Koldar Avatar asked Oct 17 '22 19:10

Koldar


1 Answers

  1. Approaches for libraries and headers locations could be different: you should place library directly into /usr/local/lib (otherwise linker will unable to find them) but may place headers under subfolder of /usr/local/include (so them will not be mixed with headers from other libraries).
  2. The question itsels is opinion-based, as there is no universal rule about installing locations. As a simple but widely used approach you may use install directories from GNUInstallDirs CMake module.

– Tsyvarev

like image 140
Armali Avatar answered Oct 21 '22 08:10

Armali