Linux, CMake and -fPIC?

Brand new to both Linux and CMake. Typically build plugins using Projucer on Windows and Mac, but decided it was time for CMake. Used one of the CMakeLists examples (helpful!) to modify and my VST3 plugin builds and runs in both AudioPluginHost and Reaper.

But won’t load in a program called JRiver Media Center. Contacting the manufacturer suggested that I build using -fPIC. I searched around the Juce forum and found:

set_target_properties(mypluginname PROPERTIES
    POSITION_INDEPENDENT_CODE ON)

Added that to my CMakes, recompiled and won’t load in JRiver, but will in AudioPluginHost and Reaper.

Added -fPIC to VS Code as a compiler argument. And see it in the c_ccp_properties.json file, and in the compile_commands.json, but after compiling still won’t load in JRiver (with no error message).

I must be missing something?

Ubuntu 20.04.5 LTS, Visual Studio Code 1.73.1 with C++ and CMake extensions.
Juce 7.0.2, GCC 9.4.0 x86_64-linux-gnu

When first opening up VS Code:

[variant] Loaded new set of variants
[kit] Successfully loaded 2 kits from /home/mitch/.local/share/CMakeTools/cmake-tools-kits.json
[proc] Executing command: /usr/bin/gcc -v
[proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT
[proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT
[cmakefileapi-driver] This version of CMake does not support the "toolchains" object kind. Compiler paths will be determined by reading CMakeCache.txt.
[main] Configuring folder: MConvolve 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/mitch/Documents/MConvolve -B/home/mitch/Documents/MConvolve/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring juceaide
[cmake] -- Building juceaide
[cmake] -- Exporting juceaide
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/mitch/Documents/MConvolve/build

Builds successfully, here is the last bit

build] [ 83%] Linking CXX static library HLConvolver_artefacts/Debug/libHLConvolver_SharedCode.a
[build] [ 83%] Built target HLConvolver
[build] [ 87%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp.o
[build] [ 87%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.cpp.o
[build] [ 89%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp.o
[build] [ 91%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp.o
[build] [ 93%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o
[build] [ 95%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp.o
[build] [ 97%] Building CXX object CMakeFiles/HLConvolver_VST3.dir/home/mitch/Documents/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp.o
[build] [100%] Linking CXX shared module HLConvolver_artefacts/Debug/VST3/HLConvolver.vst3/Contents/x86_64-linux/HLConvolver.so
[build] -- Up-to-date: /home/mitch/.vst3/HLConvolver.vst3
[build] -- Up-to-date: /home/mitch/.vst3/HLConvolver.vst3/Contents
[build] -- Up-to-date: /home/mitch/.vst3/HLConvolver.vst3/Contents/x86_64-linux
[build] -- Installing: /home/mitch/.vst3/HLConvolver.vst3/Contents/x86_64-linux/HLConvolver.so
[build] [100%] Built target HLConvolver_VST3
[build] Build finished with exit code 0

Loads in AudioPluginHost and Reaper, but not JRiver. JRiver dev showed me another VST3 that loads…

Thoughts?

Does plugin have a binary resources(juce_add_binary_data)? AFAIK only such target need to be PIC. So, if yes, then it’s possible to set it:

set_target_properties(My_Plugin_BinaryData PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
2 Likes

@KottVV You have helped me before, thank you!

Yes, I do have binary resources (images and fonts), and have added

set_target_properties(BinaryData PROPERTIES
    POSITION_INDEPENDENT_CODE ON)

The plugin looks and behaves as it should in Reaper and AudioPluginHost, but not in JRiver. Maybe it isn’t my problem, even though the JRiver dev showed me a VST3 plugin being loaded. I think I will contact them again. In the meantime, I will see if I can launch JRiver from the VSCode debugger and catch what is going on…

JRiver doesn’t load any JUCE plugin for me in Linux. I got not ideas on their forum with that. Hope you’ll get more luck :slight_smile:

Sorry, things were changed. I’ve tested it now and it works, for example with ChowTapeModel

1 Like

You could also try setting the CMake variable directly:

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Thanks @kcoul As it turns out, it was a carbon unit failure on my behalf as the 32-bit version of JRiver got installed instead of 64-bit. Ouch!

But with the 64-bit version of JRiver installed there still is an issue.

I went back to the Juce CMake example AudioPlugin and in VS Code developed a launch,json file to launch JRiver and debug the plugin.

These jassert’s come up a few times and F5 through them eventually the “Hello World” plugin appears.

I noticed these messages in the Terminal window:

++ WARN: Can't get file status for /dev/sr0:
No such file or directory
++ WARN: could not retrieve file info for `/dev/sr0': No such file or directory
++ WARN: can't open nrg image file /dev/sr0 for reading
Problem in trying to find a driver.

When I launch Reaper, with nothing else changed, no jasserts, everything works correctly and I see this in the Terminal window:

LC_NUMERIC / LANG is set to 'en_CA.UTF-8', overriding LC_NUMERIC environment to POSIX
ALSA: using mmap interleaved
JUCE v7.0.2

I can’t tell if it is a JRiver host issue, or VS Code debug configuration issue or maybe a permissions issue as JRiver is being launched from /usr/bin and Reaper is on the desktop…

JRiver tries to access cdrom drive, I think it’s not related.