Use juce_core module without the Projucer

I want to use juce_core, devices, and formats in a plugin for an environment which is not a DAW.

So, I made a header file with #define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED 1 and added some includes for the modules I would like to include. Additionally, I have a dependency folder with files with names like “include_juce_core.cpp” which include paths to the top-level .cpp files in each module (based on how Projucer sets up the files in a project).

So far, it is not going completely smoothly (i.e. horrbily); I am getting compile errors stating that <juce_core/juce_core.h> is not found, for example.

I did a bit of research into includes with <> and, perhaps, am becoming more confused than I enjoy.

I believe this is a knowledge problem. Can anyone offer any pointers to help me discover how to put this together properly?


I would be very happy to help you, but I would need more information first:

  • On which platform are you working?
  • Are you using a build system or are you invoking the compiler manually?
  • How is include_juce_core.cpp being compiled currently (what flags are passed to the compiler)?
1 Like

You are very kind.

I am working on OS X 13.2, using a makefile, and am passing flags (in the makefile) like this for the include_juce_xxx.cpp flies.

FLAGS += \
    -DTEST \

FLAGS += \
    -DTEST \

The errors received look like this -

In file included from /Users/me/Documents/SourceControl/JUCE/modules/juce_audio_basics/juce_audio_basics.cpp:32:
/Users/me/Documents/SourceControl/JUCE/modules/juce_audio_basics/juce_audio_basics.h:52:10: fatal error: 
  'juce_core/juce_core.h' file not foundIn file included from dep/include_juce_audio_formats.cpp
In file included from /Users/me/Documents/SourceControl/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:40:
fatal error: #include <juce_core/juce_core.h>
'juce_audio_basics/juce_audio_basics.h' file not found
#include <juce_audio_basics/juce_audio_basics.h>

The flag -I is most of the time used to specify an “include search path”, i.e. a path/directory where the compiler can search for files when it parses #include <foo.h> in the C++ code.

Let’s imagine that we have the following folder structure:

├── include/
│   └── a/
│       └── b.hpp
└── src/
    └── c.cpp

If c.cpp contains #include <a/b.hpp>, then we have to compile it with clang++ -Iinclude src/c.cpp (given the working directory is root).
If c.cpp contains #include <b.hpp>, then we have to compile it with clang++ -Iinclude/a src/c.cpp.

When you are compiling include_juce_core.cpp, you need to pass -Ipath/to/JUCE/modules, and then the compiler will be able to find juce_core/juce_core.h. I hope this helps.

I have another question that I should have asked in my first reply: why don’t you want to use Projucer?

1 Like

Thank you for this! I will try it when i get back to my computer.

Reason for not using the Projucer: Mainly, I am trying to understand how programs put together better having only used xCode by itself, and then Projucer/xCode up to now. Makefiles seem to require a certain clarity that I am not thrilled about lacking. I would understand if some people think that I might be insane. :wink:

Somebody who wants to learn is anything but insane!

In Xcode, you can expand the build log to see how clang is called. There will be a lot of optional flags that you can ignore for now (such as flags for warnings), but you’ll get a better idea of what flags exist and what arguments they usually take.

1 Like

Worked perfectly. Thank you so much!