Setting up a new project on Linux

I’ve managed to compile the the SDK fine in Linux and I can load the example in Reaper just fine. Now I’d like to figure out how to set things up to compile my own plugins. What should my folder structure look like? Something like this?

My_Root_Dir
-vst3sdk
-MyPlugins
-build  
-CMakeLists.txt

Also, I’m not sure what should be in CMakeLists.txt, I’ve got the following:

cmake_minimum_required (VERSION 3.19)
project(MYPLUG)
add_subdirectory(vst3sdk)

I’ve added some defines to the top level CMakeLists.txt file and it’s making some progress.

cmake_minimum_required (VERSION 3.19)
project(MYPLUG)
add_definitions(-D_DEBUG -DDEVELOPMENT)
add_subdirectory(vst3sdk)

However, it ultimately fails with errors:

source/vst/hosting/module_linux.cpp.o
[ 80%] Linking CXX executable /VST3Inspector/VST3Inspector
Error creating directory "/VST3Inspector/Resources".
make[2]: *** [vst3sdk/public.sdk/samples/vst-hosting/inspectorapp/CMakeFiles/VST3Inspector.dir/build.make:219: /VST3Inspector/VST3Inspector] Error 1
make[1]: *** [CMakeFiles/Makefile2:660: vst3sdk/public.sdk/samples/vst-hosting/inspectorapp/CMakeFiles/VST3Inspector.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Looks like it’s trying create a directory off the root of my harddrive. The result of a missing define I suspect. Not sure where to look.

Here's the initial output of cmake:
- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [SMTG] CMAKE_SOURCE_DIR is set to: /home/rjonkman/coding/VST_3.7.5
-- [SMTG] CMAKE_CURRENT_LIST_DIR is set to: /home/rjonkman/coding/VST_3.7.5/vst3sdk
-- [SMTG] Disable all VST3 samples
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "2.10.1") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'xcb'
--   Found xcb, version 1.14
-- Checking for module 'xcb-util'
--   Found xcb-util, version 0.4.0
-- Checking for module 'xcb-cursor'
--   Found xcb-cursor, version 0.1.1
-- Checking for module 'xcb-keysyms'
--   Found xcb-keysyms, version 0.4.0
-- Checking for module 'xcb-xkb'
--   Found xcb-xkb, version 1.14
-- Checking for module 'xkbcommon'
--   Found xkbcommon, version 0.10.0
-- Checking for module 'xkbcommon-x11'
--   Found xkbcommon-x11, version 0.10.0
-- Checking for module 'glib-2.0'
--   Found glib-2.0, version 2.64.6
-- Checking for module 'cairo'
--   Found cairo, version 1.16.0
-- Checking for modules 'pangocairo;pangoft2'
--   Found pangocairo, version 1.44.7
--   Found pangoft2, version 1.44.7
-- Checking for module 'fontconfig'
--   Found fontconfig, version 2.13.1
/home/rjonkman/coding/VST_3.7.5/vst3sdk/vstgui4/vstgui/uidescription/editing
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.2.9") 
-- Checking for module 'gtkmm-3.0'
--   Found gtkmm-3.0, version 3.24.2
-- Checking for module 'sqlite3'
--   Found sqlite3, version 3.31.1
-- [SMTG] SMTG_VSTGUI_ROOT is set to: /home/rjonkman/coding/VST_3.7.5/vst3sdk
-- Performing Test SMTG_USE_STDATOMIC_H
-- Performing Test SMTG_USE_STDATOMIC_H - Failed
-- Configuring done
-- Generating done

So I gave up on trying to compile my plugin outside of the SDK and opted to just replace the contents of AGain with my own code and modify the CMakeLists.txt file accordingly.

Compiling seems to go fine, but there’s an issue during linking.

[ 68%] Linking CXX shared module ../../../../VST3/Debug/sketchpad.vst3/Contents/x86_64-linux/sketchpad.so
The shared library does not export the required 'GetPluginFactory' functionmake[2]: *** [public.sdk/samples/vst/again/CMakeFiles/sketchpad.dir/build.make:270: VST3/Debug/sketchpad.vst3/Contents/x86_64-linux/sketchpad.so] Error 1
make[2]: *** Deleting file 'VST3/Debug/sketchpad.vst3/Contents/x86_64-linux/sketchpad.so'
make[1]: *** [CMakeFiles/Makefile2:1208: public.sdk/samples/vst/again/CMakeFiles/sketchpad.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Here’s my CMakeLists.txt file for my plugin.

cmake_minimum_required(VERSION 3.15.0)

project(af-sketchpad
    VERSION 1.0
    DESCRIPTION "SketchPad Looper (VST3)"
)

if(NOT SMTG_ADD_VSTGUI)
    return()
endif()


set(sketchpad_sources
    /home/rjonkman/OneDrive/coding/Looper/source/editor.cpp
    /home/rjonkman/OneDrive/coding/Looper/source/editor.h
    /home/rjonkman/OneDrive/coding/Looper/source/processor.cpp
    /home/rjonkman/OneDrive/coding/Looper/source/processor.h
    /home/rjonkman/OneDrive/coding/Looper/source/controller.cpp
    /home/rjonkman/OneDrive/coding/Looper/source/controller.h
    /home/rjonkman/OneDrive/coding/Looper/source/SVG_PATHS.h
    /home/rjonkman/OneDrive/coding/AF/AFControls.cpp
    /home/rjonkman/OneDrive/coding/AF/AFControlCore.cpp
    /home/rjonkman/OneDrive/coding/AF/AFDrawTools.cpp
    /home/rjonkman/OneDrive/coding/AF/AFGUIBasics.cpp
    /home/rjonkman/OneDrive/coding/AF/AFPathContainer.cpp
    /home/rjonkman/OneDrive/coding/AF/AF/helpers/AF_md5.cpp
    /home/rjonkman/OneDrive/coding/AF/AF/helpers/AF_Base64.cpp
)

set(target sketchpad)

smtg_add_vst3plugin(${target} ${sketchpad_sources})
smtg_target_configure_version_file(${target})

target_include_directories(${target}
        PUBLIC
            ${SMTG_VSTGUI_ROOT}/vstgui4
            ${SMTG_VSTGUI_ROOT}/vstgui4/vstgui
            /home/rjonkman/OneDrive/coding/AF
            /home/rjonkman/OneDrive/coding/Looper/source

    )


target_compile_features(${target}
    PUBLIC
        cxx_std_17
)

target_link_libraries(${target}
    PRIVATE
        sdk
        vstgui_support
)

Success!

I had forgotten to include my entry.cpp in the CMakeLists.txt.

I know this is an old thread but I’m currently working on making a VST plugin without JUCE or VSTGUI for the first time (got basic window and event handling in macOS and Windows, now starting on the Linux side of things) and found this thread while trying to figure out how to generate a VST3 project for Linux.

I thought I’d share a bash script I wrote which made creating the project a lot easier in case anyone else had similar trouble creating a VST3 project for Linux:

CMAKE=/usr/bin/cmake

CC=/usr/bin/gcc
CSTD=11
CXX=/usr/bin/g++
CXXSTD=17

OUTDIR=/home/astriid/dev/vstdev
SDKDIR=$OUTDIR/VST_SDK/vst3sdk

GENPLUG=$OUTDIR/VST_SDK/VST3_Project_Generator/Windows_x64/Resources/GenerateVST3Plugin.cmake

if [[ "$1" == "" ]]; then
	echo -e  "\n\033[0;31mError:\033[0m expected VST project name!"
	echo -en "\033[0;32mPlease enter VST project name: \033[0m"
	read VSTNAME
	echo -e ""
else
	VSTNAME=$1
fi

if [[ "$VSTNAME" == "" ]]; then
	echo -e "\n\033[0;31mError:\033[0m no VST project name entered!"
	echo -e "\033[0;31mCannot generate VST Project!\033[0m \n"
	exit 1
fi

PRJNAME=$VSTNAME
BDLNAME=$VSTNAME

CATEGORY=Instrument
VENDOR=_astriid_
IDENTIFIER=com.astriid.$VSTNAME
HOMEPAGE=
EMAIL=
PREFIX=$VSTNAME
VSTGUI=OFF

PRJDIR=$OUTDIR/$VSTNAME

function genlist() {
	local BLDDIR=$PRJDIR/$1

	if [ ! -d "$BLDDIR" ]; then
		mkdir $BLDDIR
	fi

	$CMAKE \
	-G "Unix Makefiles" \
	-S $PRJDIR \
	-B $BLDDIR \
	-DCMAKE_C_COMPILER=$CC \
	-DCMAKE_C_STANDARD=$CSTD \
	-DCMAKE_CXX_COMPILER=$CXX \
	-DCMAKE_CXX_STANDARD=$CXXSTD \
	-DCMAKE_BUILD_TYPE=$1 \
	-DSMTG_ENABLE_VSTGUI_SUPPORT=$VSTGUI	
}

$CMAKE \
$GENPLUG \
-DSMTG_VST3_SDK_SOURCE_DIR_CLI="$SDKDIR" \
-DSMTG_GENERATOR_OUTPUT_DIRECTORY_CLI="$OUTDIR" \
-DSMTG_PLUGIN_NAME_CLI="$VSTNAME" \
-DSMTG_PLUGIN_CATEGORY_CLI="$CATEGORY" \
-DSMTG_CMAKE_PROJECT_NAME_CLI="$PRJNAME" \
-DSMTG_PLUGIN_BUNDLE_NAME_CLI="$BDLNAME" \
-DSMTG_PLUGIN_IDENTIFIER_CLI="$IDENTIFIER" \
-DSMTG_MACOS_DEPLOYMENT_TARGET_CLI=10.13 \
-DSMTG_VENDOR_NAME_CLI="$VENDOR" \
-DSMTG_VENDOR_HOMEPAGE_CLI="$HOMEPAGE" \
-DSMTG_VENDOR_EMAIL_CLI="$EMAIL" \
-DSMTG_PREFIX_FOR_FILENAMES_CLI="$PREFIX" \
-DSMTG_PLUGIN_CLASS_NAME_CLI="$VSTNAME" \
-DSMTG_ENABLE_VSTGUI_SUPPORT_CLI="$VSTGUI" \
-P "$GENPLUG"

if [ -d "$PRJDIR" ]; then
	genlist Debug
	genlist Release
fi

I saved this script as projectmaker.sh and then just run it with ./projectmaker.sh [name of project] (if you don’t include the project name, the script will prompt you to enter one).
Obviously, edit the variables in the script to your vendor name, wherever you stored your VST_SDK directory, whichever compiler you choose, etc

A couple things to note:

  1. The VST will only compile if CMAKE_BUILD_TYPE=Debug or CMAKE_BUILD_TYPE=Release has been set during project generation
  2. With CMAKE_BUILD_TYPE set, running `cmake --build . --config [build type]" will not change the build type
  3. Because of 1 and 2, a separate Debug and Release directory, rather than a singular build directory, are created in this bash script
  4. The cmake script VST3_Project_Generator/Windows_x64/Resources/GenerateVST3Plugin.cmake is exactly the same script that’s located in VST3_Project_Generator/macOS/VST3_Project_Generator.app/Contents/Resources/GenerateVST3Plugin.cmake so using either cmake script will work to generate a VST project on Linux

I’m more experienced with writing my own Makefile scripts than I am with using CMake, so if anyone knows how to improve the bash script so that CMake can build the VST for both Debug and Release in one build folder on Linux, feel free to chime in :grin: