Is there a way to specify something like "sourcefile search paths"?


I have to admit that I’m feeling a bit dumb asking this because it seems to be a very basic question - but I learned almost all my programming skills just by “learning by doing” and searching the internet.

So, I’m currently working on my first “big” piece of audio software, based on JUCE, but also depending on other libraries. I manage all third party code - if possible - as a git submodule in my project and successfully included a big header-only library by adding the folder containing its submodule in the “Header Search Path” of every Exporter in the Projucer. I also managed to include another library which came as a static library with a header file, by specifying another Header Search Path for the header file and added the library name under “External libraries to link” in the Exporter.

Now I found this and I need it for my Project :smiley:

I added it as a submodule to my project, set a new Header Search path to that folder and tried including a new FilterGraph to my project and all I get is a linker error, as the linker doesn’t find the functions described in the source files. This seems quite logical to me, I believe they didn’t get compiled at all as neither the compiler knows about their existence nor does the linker know where to look after the compiled versions of these .cpp files as the linker also doesn’t know about their existence (am I right?). Now although I have a rough idea of what’s the problem here, I have absolutely no clue how to get this done right, as there is no such thing as a “Sourcefile Search path” to specify. The only solution I found as a workaround was adding the two .cpp files as existing files in the projucer’s file explorer, now it compiles and links fine.
But I think this is not the way it should be done, right? So please could you tell me
a) how the compiler & linker finds source files located in a directory beneath the project-directory
b) what is good practice to get this working and setup a project with more complex dependencies on third party libraries (also for bigger libraries, containing more than just two .cpp files)

By the way: Thank you for all help I already got here!


If I correctly understood the situation, then I believe this is exactly how it should be done, i.e. you are wrong in assuming there is another, more correct, way of doing this.

To explicitly address your questions:

a) the compiler does not “find” them, you tell it what source files to compile by adding them to the project. And the resulting object files are then linked at the link stage, too.

b) usually, a third party library that is made of many cpp files, is distributed as a (well, you named it) library, either static or dynamic, that is linked to the client code written by you at the link stage.

Then there are libraries that are headers only (like the other one you already mentioned for your project), in which case it is enough to include a main header to grab the whole library.

Finally, there are other libraries that are distributed as a single header + single cpp file (or very few of them), which are intended to be added directly to your project to be compiled in, just like any other source file written by you.
JUCE-style modules, and I believe also sqlite, fall in this category.

Note: there is a minor difference between JUCE-style modules and sqlite, though: sqlite is distributed as monolithic, very big cpp and header files, obtained by concatenation of the source files that make up the codebase. JUCE-style modules are also presented as single header + cpp files, but instead of being concatenations of the codebase, they bring the codebase in by #inclusion instead.


Okay, I think I got it. Nice to hear that I wasn’t that wrong :smiley:

In fact, the “library” I’m referring to is no library in the strict sense, it’s just a git repo containing two headers and two source files that implement a special juce component that was very useful to me, so I decided to include it as a submodule rather than just copying the source files to my source file folder.

As I mentioned before and as you said, all other “real” libraries I successfully used until now are header only libraries or come with a static or dynamic library file.

I believe I had things like JUCE modules, consisting of several .cpp files, in mind when writing the post. As there is just the need to specify a path to the module folder in the Projucer I maybe misinterpreted this path to be a general “search path” passed to the compiler where all content in this folder and its subfolders gets compiled automatically if involved in the application code. So I thought there was a similar option for other folder containing source and header files to be used in the project.

But anyway, I think I got it, thank you for clarifying things :slight_smile:


To make things work as modules like the Juce modules, the files need to be set up in a particular way and also special new files need to be written that tell the Projucer about the module.