views:

554

answers:

3

I'm starting a new C project, which is largely OSS-based. It'll also be on SourceForge, and I'd like to take this opportunity to learn established best practices for organizing this kind of code. I'm using libraries like libcurl and libz, and I'll compile it using MinGW and MSYS.

I'll be distributing copies the source of all libraries I'm using with my projet, so people downloading the source won't have to go peck and hunt for dependencies. What should I call the directory I store the libraries in? So far, I hesitate between:

  • lib, because they are libraries. However, 'lib' has a different connotation in UNIX-world.
  • src, because they are source files.
  • 3rdparty, because I didn't write it.

And where should I compile these libraries to? Should I simply configure and install them to the system root, or should I set up a directory where all libraries should compile to, and link from there? Obviously, this will have ramifications for my Makefile.

How should I go about this? Are there established conventions that I should follow? Are they written down somewhere?

+1  A: 

First, for external libraries I would use vendor, but that's just a preference.

Second, I don't think it is a good idea to install other libraries in a system root, without the users knowledge. Most importantly because this will conflict with later installed versions of those libraries. So I think the best place for these libraries would be in the same directory as your application.

You could also statically compile these libraries into your program.

Peter Stuifzand
+2  A: 

At a previous job, the standard was to install them in a directory named 3rdparty and build the libraries right there (in 3rdparty/LIBNAME/Debug, etc.).

Jim Buck
+1  A: 

We use something with the _ext or _EXT suffix (i.e MyProject_EXT) to signify that it is external to our project to store the source code of external packages that we link against.

I agree with Peter. The external libraries should be not be built into the system root as they may cause conflicts. I'd build them in their directory and then install them into a /lib directory (or maybe /extlib) that is unique to your application and link to them there.

dagorym