Compile plugin on elk.audio system

Hello,

this is a basic question about plugin compilation for elk.audio and sushi:

I try to compile my first vst3-plugin, for which I found the source on github.
The plugin compiled fine on an desktop linux system, which has
X11 and some other included libraries. But: on a desktop system cmake
builds for x86.
So I tried to compile on a raspberry pi with elk.audio installed to
see, if it builds for aarch-linux without changing the build scripts.
The compilation with cmake started but then ther was an error:

fatal error: X11/Xlib.h: No such file or directory
300 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~

so on my desktop system I would just do
sudo apt install libx11-dev
to fix this.
But elk says:
sudo: apt: command not found

Now the question is: do I have a chance to install all required libraries
(-> which command should I use instead of apt to do this on elk???)
(and: → on the desktop system there are a few more libraries
like webkit libasound2-dev lv2-dev build-essential

Is it possible to integrate more libraries into the build process???
And if not: how could I convince a desktop system to build
the plugin for aarch-linux??

Thank you for any help!!!

Hi RJazz, apt is not installed on the elk audio os image, neither is any graphic framework, as it is intended as a minimal embedded system and sushi doesn’t load the plugin editors.

Have you read the docs on cross-compiling for elk? Build Plugins for Elk — Elk DevKit documentation
The gist of it is that you can build either on a RPi directly or via the cross-compiling sdk. The end result will be the same, but you need to make you plugin headless, i.e without the editor and without linking the x11 libraries.

Regards
Gustav

I’m not used to work with cmake, so I tried to build the vst3 plugin
with the original build scripts. As I said, they run on a desktop system,
so I thought, if I could embed the X11 library they also would build
on the rpi. The x11 is not needed for the vst3 plugin, only for a
windows app to control the plugin from an external device.
So the plugin itsself should be headless and run on the elk system.
I was trying to avoid setting up new scripts for cmake.
If the libraries could be embedded somehow, the build process
itsself should run.

But if apt is not an option I don’t know how to install the x11 or other
libraries at all. On the other hand I understand, that it is not
intended to install x11 on elk because it is useless for the headless system.

So I will experiemtne with the cross compiler anyway.

Maybe there is a way to set system target on a desktiop system so,
that it compiles to aarch-linux.
I could not find the right variable to set.
I tried CMAKE_SYSTEM_PROCESSOR and some other but could
not get other targets built than x86.
Maybe you know the right variable or target definition to
let cmake build for th rpi?

In the toolchain-link there is a command:
source [path-to-extracted-sdk]/environment-setup-[aarch-name]-elk-linux

Where is the sdk to extract? Is it this one here:
Releases · elk-audio/elkpi-sdk · GitHub
???
The description partially don’t match my plugin source,
e.g. for JUCE plugins there is no line
“add_subdirectory(JUCE)” and some other differences.

On which CMakeLists.txt file does this description apply?

Sorry for the basic questions, I’m not used to build plugins with c++ and juce.

I tried some configurations, e.g. the elkpk-sdk (link above).
This provides a souce-command like this:
source /opt/elk/0.11.0/environment-setup-cortexa72-elk-linux

Trying to build (cmake -Bbuild) of my project stops with errors:

CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake:49 (message):
Could not find compiler set in environment variable CC:

aarch64-elk-linux-gcc -mcpu=cortex-a72 -march=armv8-a+crc+crypto -O2
-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
–sysroot=/opt/elk/0.11.0/sysroots/cortexa72-elk-linux.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

So I guess, first of all I would have to setup an environment with
a compatible gcc (or arch??) version (-> I don’t know where to get and how to setup this?)
and find out, which system variables to set up (-> is there any up-to-date description
available??).

Also I tried with the instructions for
“### Plugins using JUCE Version 6” on “Build Plugins for Elk
This seems to work except the last line:

AR=aarch64-elk-linux-ar make -j4 CONFIG=Release CFLAGS=“-Wno-psabi” TARGET_ARCH=“-mcpu=cortex-a72 -mtune=cortex-a72”

says:

make: *** No targets specified and no makefile found. Stop.

for the project I try to build.

Yes, that is it. It is a self extracting archive. Essentially, the steps to cross-compile a binary for elk audio os from a native linux machine are:

  • Run the sdk file to extract it somewhere on your HD
  • Run: source [path-to-extracted-sdk]/environment-setup-[aarch-name]-elk-linux (this sets up the compiler to use the correct architecture, system variables, libraries etc. You shouldn’t be setting that manually)
  • Generate your build directory using cmake (best to start from a clean build dir here)
  • Build with make or whatever you generated for.

This is a symptom of CMake not being able to generate the makefile. What error were you getting from CMake when you were generating?

CMake was running without errors, this is the output:

– RTNeural - Using xsimd backend
– Configuring juceaide
– Building juceaide
– Exporting juceaide
– VERSION for JUCE: 6.0.8
– Using the single-header code from […myproject]/modules/json/single_include/
– Building LV2 plugin format
– Configuring done
– Generating done
– Build files have been written to: […myproject]

Your question seems to help a lot: after I realized, that cmake seemed to
be successful (!), I tried to run the last step:

AR=aarch64-elk-linux-ar make -j (enter number of cores) CONFIG=Release CFLAGS=“-Wno-psabi” TARGET_ARCH=“-mcpu=cortex-a72 -mtune=cortex-a72”
one directory level above x-build and it seems that this also was successful.
At the end it says:
[100%] Built target NeuralPi_Standalone
[100%] Built target NeuralPi_VST3

So it seems I’m on the right way now.
But is there maybe some other step to do:
there still is not aarch directory with a [myproject].so vst3 plugin?

After some try and error builds I could set up a new project most exactly along
the description in Gustavs link. There are some details different in
my versions of the github download (e.g. unset(ENV{ASM}) is in line 63). But
I think, the main configuration should be o.k…
The command

source /opt/elk/0.11.0/environment-setup-cortexa72-elk-linux
runs without errors, but

cmake …/ -DCMAKE_BUILD_TYPE=Release

gives and error:

CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake:49 (message):
Could not find compiler set in environment variable CC:

aarch64-elk-linux-gcc -mcpu=cortex-a72 -march=armv8-a+crc+crypto -O2
-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security
–sysroot=/opt/elk/0.11.0/sysroots/cortexa72-elk-linux.
Call Stack (most recent call first):
CMakeLists.txt:17 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
– Configuring incomplete, errors occurred!

now, some hours later:
I found out, that the last error was due to rights and path problems
which I could solve.
Now the next error is:
bash: /opt/elk/0.11.0/sysroots/cortexa72-elk-linux/usr/bin/cmake: cannot execute binary file: Exec format error

Does it after all still have to be compiled on the elk system?

file:

file /opt/elk/0.11.0/sysroots/cortexa72-elk-linux/usr/bin/aarch64-elk-linux-gcc
says:
/opt/elk/0.11.0/sysroots/cortexa72-elk-linux/usr/bin/aarch64-elk-linux-gcc: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=ccba6511a8b68daa2da6b3ab207d4ee40eb09427, for GNU/Linux 3.14.0, stripped

Are you running this file directly? You should not do that, as it is compiled for the RPi system (arm64). You should run the normal cmake in you system. If you’ve run the source [path to sdk] command before that, it should have exported all the necessary variables for cmake to know that you are compiling for a different architecture.

Thank you for your answer.
Now I tried to do a simple test.
just copied a simple plugin in a newu directory
then I started this command:

source /opt/elk/0.11.0/environment-setup-cortexa72-elk-linux

And afterwards just typed:

cmake .

This leads to an error:

– The C compiler identification is unknown
– The CXX compiler identification is unknown
– Detecting C compiler ABI info
– Detecting C compiler ABI info - failed
– Check for working C compiler: /opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-elk-linux/aarch64-elk-linux-gcc
– Check for working C compiler: /opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-elk-linux/aarch64-elk-linux-gcc - broken
CMake Error at /opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler

"/opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-elk-linux/aarch64-elk-linux-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/xxx/testPlugin/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake cmTC_28ab4/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_28ab4.dir/build.make CMakeFiles/cmTC_28ab4.dir/build
gmake[1]: Entering directory '/home/xxx/testPlugin/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_28ab4.dir/testCCompiler.c.o
/opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-elk-linux/aarch64-elk-linux-gcc   -O2 -pipe -g -feliminate-unused-debug-types   -o CMakeFiles/cmTC_28ab4.dir/testCCompiler.c.o -c /home/xxx/testPlugin/CMakeFiles/CMakeTmp/testCCompiler.c
as: unrecognized option '-EL'
gmake[1]: *** [CMakeFiles/cmTC_28ab4.dir/build.make:85: CMakeFiles/cmTC_28ab4.dir/testCCompiler.c.o] Error 2
gmake[1]: Leaving directory '/home/xxx/testPlugin/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_28ab4/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:17 (project)

– Configuring incomplete, errors occurred!

Even if I just let gcc compile a simple test.c on the command line like this:

/opt/elk/0.11.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-elk-linux/aarch64-elk-linux-gcc test.c

I get the same error:

as: unrecognized option ‘-EL’

while

gcc test.c

works fine.

Another annotation:
the error also occures WITHOUT running
the script (/opt/elk/0.11.0/environment-setup-cortexa72-elk-linux) before.

I found out: this error occured, because the wrong ar version
was loaded. I could fix this, but now got some new
errors, at the moment like this:

gmake[1]: /home/xxx//elk/1.0/sysroots/cortexa7t2hf-neon-vfpv4-elk-linux-gnueabi/usr/bin: Permission denied

(I even tried → chmod -R 777 usr
withhout success).

So I guess, there are still some substantial problems to solve with
my crosscompile toolchain.

So I guess, I will try this alternatively:

Cross compiling JUCE 6.1.6 results in juceaide being compiled with target toolchain

Now, again some steps further:
I could compile a simple hello.c for aarch64 (yeah!)
with docker like in the link above (thanks to valentinlageard).

The next step: compile a real VST3 plugin.
In this scenario there is an error with finding files in the sysroots/cortexa72-elk-linux files:

In file included from
/workdir/sysroots/cortexa72-elk-linux/usr/include/sys/cdefs.h:463:0,

                 from /workdir/sysroots/cortexa72-elk-linux/usr/include/features.h:473,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/bits/atomic_base.h:35,
                 from /usr/include/c++/7/atomic:41,
                 from /workdir/x-build/modules/JUCE/tools/check_atomic_GsCSdXNz4OwUOwim.cpp:1:




/workdir/sysroots/cortexa72-elk-linux/usr/include/bits/long-double.h:23:10:
fatal error: bits/long-double-32.h: No such file or directory



 #include <bits/long-double-32.h>
          ^~~~~~~~~~~~~~~~~~~~~~~

Is it a problem with cmake options (not to take 32-bit or so???) or are the files really missing
(or any other alternative :wink: ?