Here is how I compiled helmoltz~
. As mentioned earlier, there is no standard way of compiling externals, and each and everyone of them will probably require inspecting the Makefile
at some point to get it to build.
Steps:
- get the source code and copy it to the board:
scp -r helmoltz~ root@192.168.7.2:
- ssh to the board and navigate to the helmoltz~
folder:
ssh root@192.168.7.2
cd helmoltz~
- inspect the files in the folder:
- navigate to the
src/
folder where there is a Makefile
:
cd src
- for good measure, run
make clean
to get rid of any leftover pre-built files
- try to run
make
and see if/how it fails
root@bela:~/helmholtz~/src# make
g++ -DPD -O3 -Wall -W -Wshadow -Wno-unused -Wno-parentheses -Wno-switch -fcheck-new -fvisibility=hidden -I ./include -c *.cpp
g++ -bundle -undefined suppress -flat_namespace -o helmholtz~.pd_darwin *.o
g++: error: suppress: No such file or directory
g++: error: unrecognized command line option ‘-bundle’; did you mean ‘-Wundef’?
g++: error: unrecognized command line option ‘-flat_namespace’; did you mean ‘-Wnamespaces’?
Makefile:44: recipe for target 'helmholtz~.pd_darwin' failed
So it seems it is trying to build a helmholtz~.pd_darwin
external, which would be for macos. We need to rectify this. Open Makefile
in your favourite text editor, and you will see the first target (which is the default target) is:
current: pd_darwin
Scroll down and you will see that there is a target called pd_linux
.
So the next thing to try is to run make
with that target:
root@bela:~/helmholtz~/src# make pd_linux
g++ -msse -DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -Wall -W -Wshadow -Wno-unused -Wno-parentheses -Wno-switch -fvisibility=hidden -I ./include -c *.cpp
g++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’?
Makefile:23: recipe for target 'helmholtz~.pd_linux' failed
make: *** [helmholtz~.pd_linux] Error 1
The error her is that it is trying to use -msse
, which instructs the compiler to use the sse
instructions, but these are only available on Intel CPUs. So open the Makefile
again, and see where these are defined:
LINUXCFLAGS = -msse -DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC\
-Wall -W -Wshadow \
-Wno-unused -Wno-parentheses -Wno-switch -fvisibility=hidden
Now, with make
, the internal variables can be overridden from the command-line, without editing the Makefile
, so we can use this feature to remove the -msse
option. Inspecting the current list of options, we see that many of those (those starting with -W
) refer to warnings, so we can just remove them. While we are at it, we can add in the standard Bela optimization options (which can be found in ~/Bela/Makefile
): -O3 -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math
. Let's not remove the -D
options (which define flags that are used by the code).
The resulting LINUXCFLAGS
variable should then contain: -DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -fvisibility=hidden -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math
. We can therefore execute the following command:
make pd_linux LINUXCFLAGS="-DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -fvisibility=hidden -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math"
This fails like this:
In file included from Helmholtz.cpp:14:0:
./include/Helmholtz.h:53:18: fatal error: m_pd.h: No such file or directory
#include "m_pd.h"
^
compilation terminated.
helmholtz~.cpp:12:18: fatal error: m_pd.h: No such file or directory
#include "m_pd.h"
^
compilation terminated.
Makefile:23: recipe for target 'helmholtz~.pd_linux' failed
make: *** [helmholtz~.pd_linux] Error 1
This means that we need to tell make
where to find our m_pd.h
file. This is in /usr/local/include/libpd
. We can simply add -I/usr/local/include/libpd
to the LINUXCFLAGS
:
make pd_linux LINUXCFLAGS="-DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -fvisibility=hidden -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -I/usr/local/include/libpd"
This produces the following output:
g++ -DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -fvisibility=hidden -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -I/usr/local/include/libpd -I ./include -c *.cpp
g++ -Wl -export-dynamic -shared -o helmholtz~.pd_linux *.o -lc -lm -lstdc++
g++: error: unrecognized command line option ‘-Wl’; did you mean ‘-W’?
Makefile:23: recipe for target 'helmholtz~.pd_linux' failed
make: *** [helmholtz~.pd_linux] Error 1
The first line is the compiling step and it actually works ok. The second line is the linking stage and it fails because of the -Wl
option. Not sure here what the original developer meant by that. Options starting with -Wl,
normally contain flags to be passed to the linker, but this one is incomplete, so we can just remove it. Inspecting the Makefile
once more, we see that the -Wl
option is actually hardcoded in the recipe for pd_linux:
, so we cannot override it from the command line and we have to delete it manually from the Makefile
. Once that is done, we can re-run the command above and this time we obtain:
g++ -DPD -DUNIX -DICECAST -O3 -funroll-loops -fomit-frame-pointer -fcheck-new -fPIC -fvisibility=hidden -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -I/usr/local/include/libpd -I ./include -c *.cpp
g++ -export-dynamic -shared -o helmholtz~.pd_linux *.o -lc -lm -lstdc++
rm -f *.o ../helmholtz~.pd_linux
cp helmholtz~.pd_linux ../helmholtz~.pd_linux
Success! The generated file is in ~/helmholtz~/src/helmholtz~.pd_linux
, and also it is copied in /root/helmholtz~/helmholtz~.pd_linux
. We now can copy this file to ~/Bela/projects/pd-externals
, after creating the folder (in case it doesn't exist):
mkdir -p ~/Bela/projects/pd-externals
cp ~/helmholtz~/src/helmholtz~.pd_linux ~/Bela/projects/pd-externals/