Rasbperry pi build of demoruner using cmake

I used JUCE on a pi for a simple project years ago with no problem. But I am unable to build the demo on a pi right now (Juce 6).

I installed the required build packages and tried building and failed. I am trying to use cmake. I first had to build openssl from source, then cmake from source. ( I was successful at doing this for an x86 ubuntu system). But on the pi(raspbian) I get this for the error when building the demorunner:

pi@raspberrypi:~/JUCE $ cmake --build cmake-build --target DemoRunner
[ 0%] Building CXX object examples/DemoRunner/CMakeFiles/DemoRunner.dir///modules/juce_dsp/juce_dsp.cpp.o
In file included from /home/pi/JUCE/modules/juce_dsp/juce_dsp.cpp:105:
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:360:32: error:
use of undeclared identifier ‘SIMDRegister’
auto numSIMDElements = SIMDRegister::SIMDNumElements;
^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:360:45: error:
unexpected type name ‘NumericType’: expected expression
auto numSIMDElements = SIMDRegister::SIMDNumElements;
^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:360:59: error:
no member named ‘SIMDNumElements’ in the global namespace
auto numSIMDElements = SIMDRegister::SIMDNumElements;
~~^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:494:28: error:
use of undeclared identifier ‘SIMDRegister’
static AudioBlockUnitTests<SIMDRegister> audioBlockSIMDFloatUnitTests;
^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:494:46: error:
expected ‘(’ for function-style cast or type construction
static AudioBlockUnitTests<SIMDRegister> audioBlockSIMDFloatUnitTests;
~~~~~^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:495:28: error:
use of undeclared identifier ‘SIMDRegister’
static AudioBlockUnitTests<SIMDRegister> audioBlockSIMDDoubleUnitTests;
^
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:495:47: error:
expected ‘(’ for function-style cast or type construction
static AudioBlockUnitTests<SIMDRegister> audioBlockSIMDDoubleUnitTests;
~~~~~~^
7 errors generated.
make[3]: *** [examples/DemoRunner/CMakeFiles/DemoRunner.dir/build.make:346: examples/DemoRunner/CMakeFiles/DemoRunner.dir///modules/juce_dsp/juce_dsp.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:1112: examples/DemoRunner/CMakeFiles/DemoRunner.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:1119: examples/DemoRunner/CMakeFiles/DemoRunner.dir/rule] Error 2
make: *** [Makefile:353: DemoRunner] Error 2

I don’t know if there is something missing on my install, something different on raspbian vs ubuntu or is it architecture related.

Has anyone tried to build the demorunner on a pi at version 6? Did you have this problem and if so, how did you resolve it??

I tried building some juce stuff a few weeks ago on the Pi 4 with juce 6. I cant remember running into this exact error but I did have a lot of trouble getting things to compile with gcc. The issue I remember running into was with the atomic library not being linked and maybe a few others. I believe I was successful using clang instead of gcc so you might try that. I was for sure able to compile the audio plugin host using clang. I did not ever try the demo runner though. Looking at your errors it seems you might be missing SIMD support. What model Pi are you using?

Ive been cross compiling my juce project for the pi the last couple weeks now and its a lot easier than having to compile stuff on the pi since it tends to take a lot longer (although it was sort of challenging building the toolchain)

I had the atomic problem and the fix was simply adding -latomic to the link. But this build is not getting that far. I am building on a rpi 3 but that shouldn’t matter. I have no idea how to use clang. (I’m and old timer, clang is new to me).

How do I switch to clang?

Yeah I had never used clang either before I tried it out on the pi. You can download clang through the package manager apt (I think, I dont think I built it from source but maybe I did). For forcing cmake to use clang instead of gcc you can use the compiler options when running the cmake command:

cmake -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

If raspbian uses the alternative thing like ubuntu has, you may also be able to set clang as the gcc alternative and not have to use the flags every time. I think this essentially just updates the compiler symlinks to link to clang instead of gcc.

1 Like

I dont understand. I have been using this to build:

cmake --build cmake-build --target DemoRunner

This gives me the error. If I try specifiying the compiler like this:

cmake -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ --build cmake-build --target DemoRunner

the error:
CMake Error: The source directory "/home/pi/JUCE/--target" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

If I reverse the order:
cmake --build cmake-build --target DemoRunner -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

I get:

/usr/bin/make: invalid option -- 'D'
/usr/bin/make: invalid option -- 'D'
Usage: make [options] [target] ...

(Clang is installed.  I had a pi 4 4gig laying around, so I put a new sd card in and started from scratch and results are the same)

(By the way, I can build the projucer with make if I add -latomic to the linker flags in the makefile

So how do I compile this with clang?

I think you need to specify the compiler flags when you generate the build directory files.

So the commands would be something like this:

cmake -B cmake-build  -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

Then once the build directory is generated you run

cmake --build cmake-build --target DemoRunner

I tried that and got the error:
pi@raspberrypi:~/JUCE $ cmake --build cmake-build --target DemoRunner
make: *** No rule to make target ‘DemoRunner’. Stop.

I realized that the first line was missing the build examples and extras so I tried this line:
cmake -B cmake-build -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DJUCE_BUILD_EXAMPLES=ON -DJUCE_BUILD_EXTRAS=ON

Same result. So I tried reversing the order:
cmake -B cmake-build -DJUCE_BUILD_EXAMPLES=ON -DJUCE_BUILD_EXTRAS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

This builds but fails with the same SIMDRegister error:
[100%] Building CXX object examples/DemoRunner/CMakeFiles/DemoRunner.dir///modules/juce_box2d/juce_box2d.cpp.o
[100%] Building CXX object examples/DemoRunner/CMakeFiles/DemoRunner.dir///modules/juce_dsp/juce_dsp.cpp.o
In file included from /home/pi/JUCE/modules/juce_dsp/juce_dsp.cpp:105:
/home/pi/JUCE/modules/juce_dsp/containers/juce_AudioBlock_test.cpp:360:32: error: use of undeclared identifier ‘SIMDRegister’
auto numSIMDElements = SIMDRegister::SIMDNumElements;
^

Think the problem is that the JUCE_USE_SIMD is true and probably should be false for the pi. I tried adding -DJUCE_USE_SIMD=OFF (tried 0 too) but it builds too fast and files the same way. I assume I need to do the equivalent of ‘make clean’. How do I do that with cmake?

I just built the projucer, the loaded the demorunner.jucer. I added preprocess definition JUCE_USE_SIMD=0.

Then tried to build the project with make and I still get the same error. make -n shows I am getting the flag set to 0. I don’t know where to go from here? It shouldn’t be this hard to simply build the demo.

So I pulled 5.x and it failed the same way.
Pulled 4.3.1 and it uses the old demo (not demo runner).
This built and ran on the first try.

if you want to do a clean build just remove the old build directory and then regenerate it using that cmake -B … command

it looks like that audio test in juce_AudioBlock_test.cpp might not be using the flag and just always uses SIMD regardless. Can you disable unit tests (probably a flag for it) so that the test doesnt get compiled?

Did some digging and found this post here. Looks like the problem is indeed that the test uses SIMD when it shouldnt. He provided a patch so you could add his modifications to your juce install. This might be something that got fixed on the develop branch so you could try pulling the develop branch of juce instead of master (id try that first before patching it yourself). Or just disable unit tests. That might be the easiest

1 Like

OK,I figured out how to disable unit tests and it build and runs now. However, there may be a problem still.

I started demorunner, then selected utility, and started the multithread test and it worked but seems to run in slo motion. When clicking on thread type to select thread pool, nothing happens. I cannot even terminate the demo. It does not respond to any mouse clicks.

I then tried running the demo build with 4.3.1, and the demo runs well. I can change thread type and everything seems fine. The slow motion does not exist there.

Is this the demo redisign from demo to DemoRunner that is causing performance problems or has Juce regressed along the way???

hmm not really sure I can help you there. Not sure what might be going on. I haven’t noticed any sluggishness or anything on my pi 4, but I havent run the demo. Ive run a fairly intensive tracktion engine app and it does fine.

A little more info. The example above was run using rdp from a windows machine. I connected a 4k monitor and tried it on a local desktop. Drastically different.

The 4.x demo. Runs for a couple seconds then locks up. Top shows 375% cpu, 5 JuceDemo process running and everything locks up.

The 6.x demo runs slow but does not bring the system down. Still does not repond to mouse clicks but works. Top shows 80% cpu and only one process.

Clearly the threading is different between either JuceDemo and DemoRunner, or between Juce 4 and Juce 6.