-1

I'm currently working on a C++ library to use in other projects and uses a few other libraries (like Nlohmann JSON, PrettyPrint, GTest, etc.). What I'm trying to figure out is where to put all of these libraries and ensure that the necessary ones are included in the projects that use this library. Currently, my project structure looks like:

Library/
  config/ <- Premake and build files
  include/ <- Actual header files
  lib/ <- Current home of all library files
  src/ <- Source files of library
  libLibrary.a <- Compiled library

What recommendations would anyone have for restructuring to make it so that projects using this library needs a minimal number of steps to include and use it?

iHowell
  • 2,263
  • 1
  • 25
  • 49
  • According to [Linux Directory structure](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard#Directory_structure) You must put your executable in `/usr/bin` and the `.so` files it requires (not other packages) in `/usr/lib` – Ripi2 Dec 14 '18 at 17:35

1 Answers1

1

If it's .a then that's statically compiled and built-into your final library file, so it's not necessary to include it.

If it's shared (.so) and system-provided then you don't have to worry about it either.

It's only shared libraries that aren't system that you need to concern yourself with, and if that's the case you need to provide specific instructions on how to install and use your library with its shared dependency.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • So, since it's statically compiled, I could just keep it as is, drop the library into the `lib` folder of a project, and use `-Ilib/Library/include -llib/Library`? – iHowell Dec 14 '18 at 17:30
  • 1
    You'll want to use a tool like [`ldd`](https://stackoverflow.com/questions/50159/how-to-show-all-shared-libraries-used-by-executables-in-linux) on the resulting binary to show the shared library dependencies. Statically compiled libraries should not be listed, so yes, those can be omitted from your final distribution as they're baked in. If this is something you're distributing you may want to look at making a proper package for it (e.g. APT, DNF/YUM, Homebrew or otherwise). – tadman Dec 14 '18 at 17:35