4

I am not sure this strictly a programming question, so I apologize if it is not.

I developed a few libraries in C++ that I mean to use in several different projects. Till now I kept copying the updated library in the folders of the various projects. As you can imagine this is not ideal, so I would like to create a "3rd-parties" folder where I save the libraries I write and other that I might download in the future.

How can I do this? And considering I'll want to share/release my code later on what is the best strategy to be sure that the used libraries are included in the code I deploy?

Asherah
  • 18,948
  • 5
  • 53
  • 72
lucacerone
  • 9,859
  • 13
  • 52
  • 80

2 Answers2

6

There are no hard and fast rules. But if these are 1) general-purpose, for 2) global sharing, then I'd suggest /usr/local/lib (for your .a and .so libraries) and /usr/local/include (for the corresponding headers).

Here's a good description of "standard file locations" for Linux:

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • 1
    Thanks Paulsm, actually for the moment I'm still developing them, but already using them in a few projects. Probably the best for me is to use them as suggested by Anon and move them when they're stable enough. Just a small question.. what are .a and .so files? When I compile my libraries I always obtain .o or .d files.. – lucacerone Aug 11 '12 at 12:30
  • @LucaCerone:- .a is archive file in linux and .so is shared object library files..More info at http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html – perilbrain Aug 11 '12 at 15:11
2

If you want to share your modules with new project its better to organise them in a single folder and mark this folder as included library path in your new projects.

perilbrain
  • 7,961
  • 2
  • 27
  • 35
  • Ok Anon, and how do I do this? I'm a rookie programmer (unless you don't count Matlab programming) and all of this is a bit new to me.. In particular what I don't get is: marking the folder as included library path is a compiler thing? or an Ide thing? (or is it a compiler thing that can be managed by IDEs like Eclipse, just to mention the one I use :p) – lucacerone Aug 11 '12 at 08:24
  • Yes, exactly. Whatever compiler or IDE you use, you should be able to specify 1) a path for #include files ("-I" for gcc) and 2) a path for library files ("-l" for ld). – paulsm4 Aug 11 '12 at 08:27
  • both...These links will help you :) :- http://stackoverflow.com/questions/2726993/g-how-to-specify-preference-of-library-path ,http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html – perilbrain Aug 11 '12 at 08:28