Trying to make a headless build, but the example CMake ConsoleApp still wants X11, am I missing something?

Hi!

I want to build a headless VST3 plugin for the RPi4. The X-compilation SDK I’m using contains no X11 headers whatsoever, and when I follow JUCE’s instructions to build the example CMake ConsoleApp, I get the following:

CMake Error at JUCE/extras/Build/juceaide/CMakeLists.txt:86 (message):
  Failed to build juceaide
(...)
ConsoleApp/JUCE/modules/juce_gui_basics/juce_gui_basics.h:319:12:
  fatal error: X11/Xlib.h: No such file or directory

    319 |   #include <X11/Xlib.h>
        |            ^~~~~~~~~~~~

  compilation terminated.

What I’ve done is:

  1. Copied the ConsoleApp folder out from JUCE/examples/CMake/, into its own folder.
  2. Cloned a Fresh copy of JUCE as a subdirectory of ConsoleApp.
  3. Edited ConsoleApp/CMakeLists.txt uncommenting line 28, to include JUCE (add_subdirectory(JUCE)) .
  4. Typed $ unset LD_LIBRARY_PATH
  5. Typed $ source /path/to/RPi4/x-compilation/sdk
  6. Ran CMake.

Since the SDK is for a platform lacking X11, I get the error I pasted earlier.
Is it so that the SDK needs the X11 headers?

From what I found in this forum, if a JUCE binary doesn’t find X11 during runtime, it defaults to running as headless. But I’ve found no mention on how to build, using CMake, without pulling in X11 headers.

Any ideas? Thanks in advance!

My understanding is that the runtime check is more general than that - it checks if there are no displays connected - so in theory headless could be possible on any OS, not just Linux (as long as that OS can boot without displays).

As for compile time, I resorted to pulling in the headers as I wanted to build apps and plugins that could be both headless and gui-attached, so the runtime check worked better in my case. I do think it would be better to do away with the compile-time dependency for fully headless builds, but I suppose there would need to be some way of communicating the intent of building a fully headless binary to the build system (which I suppose is juceaide, an internal I’d like to learn more about).

1 Like

The X11 headers are required to build JUCE projects and you can find the required dependencies here:

At runtime JUCE will load the X11 libraries dynamically and, if they aren’t present on the machine, will fall back to a “headless” app with no GUI support.

2 Likes

Good to know. While I did see that, I was wondering how that interacted with the headless case, hence my asking.

I’ll find a way to pull in the headers for getting it to build then, thank you!