Writing my first JUCE module - how to include JUCE headers right?

I want to start packaging some stuff I plan to re-use and maybe to share into juce modules.

Now for an example, right now I’m subclassing juce::Logger to create a logger that writes to the Mac Console.app. It’s currently a simple set of header and source files in my project’s Source folder, where the header file has the usual #include "../JuceLibraryCode/JuceHeader.h" statement to make all JUCE stuff accessible. Now what should I include into the header file if I put it into a module? Obviously, the JuceHeader.h approach won’t work here. Should I include <juce_core/logging/juce_Logger.h> or how is it intended to be done?

I just don’t want to do anything that doesn’t comply with the general idea of juce modules :wink:

I do it like this:

in the my_module.h I include first the modules, I depend on, and afterwards I include my own headers:


  ID:            my_module
  vendor:        My Company.
  version:       0.9.0
  name:          This is my first module
  description:   Does cool stuff
  dependencies:  juce_core
  website:       www.juce.com
  license:       Proprietary


#pragma once

#include <juce_core/juce_core.h>

#include "my_module_MyClass.h"
#include "my_module_AnotherClass.h"

Note about importing namespaces, I usually add juce:: to all juce classes in my headers, so I don’t need to call using namespace juce (being a bit of a control freak :wink: )
It is fine then to use them without the namespace in the cpp files.

Now in your implementation files, you only need to include the

#include "../JuceLibraryCode/JuceHeader.h"

But there might be more elegant ways, I’m curious as well…



Thank you, that seems sensible. I got it all working & just released the (probably) smallest module ever released, mainly for my personal training purposes :wink: