Splitting up a large project into subfolders?

Andras Mantia amantia at kde.org
Thu Jun 10 21:05:07 UTC 2004

Simon Ejsing wrote:

> I suppose the right way is to create a subproject for the files, but how
> can I generate regular .o files and link them into the main project?
You must use static libaries. One library for each subdirectory. Example:

In the Makefile.am of subdir1 you put:
noinst_LTLIBRARIES = libsubdir1.la
libsubdir1_la_SOURCES = texture.h texture.cpp

In the Makefile.am of cppproject:
bin_PROGRAMS= your_app
your_app_LDADD = $(top_builddir)/subdir1/libsubdir1.la
AM_CPPFLAGS= -I$(top_srcdir)/subdir1

This is the minimum, so you can use texture.h in main.cpp by simply using 
#include "texture.h"
and the texture.o will be put in libsubdir1.a which will be linked with the
main.o to create your_app.

I don't know the steps how you can do this from KDevelop, but I'm pretty
sure it's possible. You just have to create a right target (the libraries)
and set the flags.

Of course, if you use system libraries and header files, you must add the
correct flags to the *_LDADD, AM_CPPFLAGS and *_LDFLAGS lines.
Get an existing KDE app and verify how it's done there.

IMHO this is an user question and it's far from being a bug. There are many
project in KDE that are using subdirectories and subprojects.


More information about the KDevelop-devel mailing list