[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Advice on the project structure for a library

From: Jef Driesen
Subject: Advice on the project structure for a library
Date: Tue, 03 Jun 2008 10:00:07 +0200
User-agent: Thunderbird (Windows/20080421)

I'm creating my first autoconf/automake project and need some advice on
the standard way to structure my project source code (if there is such a
thing). My project consist of a (libtool) library and a few example
applications that are using the library.

Right now my directory structure is as follows:

\, toplevel
\src, *.h and *.c files for the library
\examples, *.h and *.c files for the examples

I noticed it is common practice to install the public headers to $includedir/libfoo (rather than straight into $includedir), especially when the library has multiple public header files. So that's what I'm doing.

For applications depending on the library, I noticed there are two approaches in use:

#include <libfoo/header.h>


#include <header.h>

I think the first one is preferable (but I might be wrong), because it makes it very clear from which library the header file is included. And there is also no possibility of conflicts with a header file of the same name from another package.

But how do structure my project to make this work? Everything I tried fails to build either the library or the examples, because of problems with finding the header files. For instance, if I use the <libfoo/header.h> style include in my project, it fails to build anything, because the header files are not installed yet and thus can't be found.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]