1: the SDK examples

Firstly you need to download and install code blocks from here. You’ll want the binary release unless you fancy compiling it yourself. There are two options available for the binary release. One larger download which comes with MinGW bundled, and another smaller download which is just code::blocks on its own. If you downloaded and set up MinGW from the old tutorials then you can go ahead and download the smaller file, otherwise you’ll need the larger download.

If you didn’t do the older command line tutorials, then you’ll also need to get a copy of the VST standard development kit (SDK) from here.

Once you have code::blocks up and running, you’ll notice that it looks very similar to every other development environment. One very nice feature of the IDE is that it will allow you to import Microsoft VS files, converting all the project settings and compiler flags to work with gcc. This is a lazy way to build the examples supplied with the SDK, however, it’s good to know how to make a project from scratch just for reference. The following instructions show you how.

If you want to noodle with the source then I suggest you copy the source files from \vst2.x\**plugname**\source\ to the code::blocks project directory you’re working on and then include the copied files in the build rather than the originals. This prevents you from messing up the examples bundled with the SDK.

How to make AGain
The most simple plugin of the bunch is “again”, allowing you to change the gain of an input signal. After you have compiled this example, the dll can be found in the bin folder within your project folder.

1) Make new EMPTY project and call it “again” – you can save this anywhere on your system. code::blocks will automatically make a new folder with the name of your project in a location of your choice. You do not have to create a new directory first.

2) Assuming you have put the sdk at c:\vstsdk2.4, then right click on the project you have just created, select build options, got to the ’search directories’ tab and add c:\vstsdk2.4 to the list.

3) Right click on the project and select add files. Add the following:
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\again.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\again.h

4) Right click on the project, select ‘Properties’, navigate to the ‘Build targets’ tab and select ‘Dynamic library’ from the ‘Type’ drop down list.

5) Right click the project, select ‘Build options’ go to the linker settings tab and under ‘Other linker options’ add the following:
-def C:\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def

6) Build the project.

How to make ADelay
1) Make new EMPTY project and call it “adelay” – you can save this anywhere on your system

2) Assuming you have put the sdk at c:\vstsdk2.4, then right click on the project you have just created, select build options, got to the ’search directories’ tab and add c:\vstsdk2.4 to the list.

3) Right click on the project and select add files. Add the following:
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\adelaymain.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\adelay.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\adelay.h

4) Right click on the project, select ‘Properties’, navigate to the ‘Build targets’ tab and select ‘Dynamic library’ from the ‘Type’ drop down list.

5) Right click the project, select ‘Build options’ go to the linker settings tab and under ‘Other linker options’ add the following:
-def C:\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def

6) Build the project.

How to make Surrounddelay
This is just like adelay but has a GUI. This involves the inclusion of some extra files and some standard windows libraries.

1) Make new EMPTY project and call it “surrounddelay” – you can save this anywhere on your system

2) Assuming you have put the sdk at c:\vstsdk2.4, then right click on the project you have just created, select build options, got to the ’search directories’ tab and add c:\vstsdk2.4 and also C:\vstsdk2.4\vstgui.sf\vstgui and also C:\vstsdk2.4\public.sdk\source\vst2.x to the list.

3) Right click on the project and select add files. Add the following:
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp
C:\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp
C:\vstsdk2.4\vstgui.sf\vstgui\aeffguieditor.cpp
C:\vstsdk2.4\vstgui.sf\vstgui\vstcontrols.cpp
C:\vstsdk2.4\vstgui.sf\vstgui\vstgui.cpp

If you want to change the source then copy all this stuff to your project directory and add it, otherwise just add it in place . . .
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\surrounddelay.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\surrounddelay.h
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\adelay.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\source\adelay.h
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\editor\sdeditor.cpp
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\editor\sdeditor.h
C:\vstsdk2.4\public.sdk\samples\vst2.x\adelay\editor\resources\surrounddelay.rc

4) Right click on the project, select ‘Properties’, navigate to the ‘Build targets’ tab and select ‘Dynamic library’ from the ‘Type’ drop down list.

5) Right click the project, select ‘Build options’ go to the linker settings tab and under ‘Other linker options’ add the following:
-def C:\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def

6) Right click the project, select ‘Build options’ go to the linker settings tab and add the following to ‘Link Libraries’:
uuid
ole32
kernel32
gdi32
user32

7) Build the project.

sdelay

If you managed this then you shouldn’t have any trouble building the synth example.

  1. February 15, 2010 at 13:48

    if you get the error

    \mingw\lib\libmingw32.a(main.o):main.c:(.text+0x104)||undefined reference to `WinMain@16’|

    then remember to set your project build targets to ‘Dynamic Link Library’

    😉

  2. Steve
    February 15, 2010 at 15:31

    Hello!

    My name is Steve and I’m actually making a VST instrument as part of a college project. The fun thing is I don’t know C++ and I’m learning that as I go. But the reason I’m leaving this comment is to ask, in the AGain example, what do you need to include in the main method in order for a release to be built?

  3. James
    March 8, 2010 at 00:52

    I managed to build aGain, but when building Surrounddelay I get :

    Linking dynamic library: bin/Release/aGain.dll
    i586-mingw32msvc-g++: obj/Release/home/valkyr/Documents/vstsdk2.4/public.sdk/samples/vst2.x/adelay/editor/resources/surrounddelay.res: No such file or directory

  4. James
    March 8, 2010 at 01:58

    Figured the problem. I’m on Linux and the build process was skipping the .rc file because the MinGW32 resource compiler wasn’t set (i586-mingw32msvc-windres).

  5. Julien
    August 23, 2010 at 16:52

    Hello! I am a newbee in VST programming, and I already need your help.

    Following the previous instructions to build the examples projects, I had no issue with again and adelay project, but I got this error when trying to build surrounddelay project:

    F:\Pro\VST\surrounddelay\sdeditor.cpp|18|error: ../adelay.h: No such file or directory|
    F:\Pro\VST\surrounddelay\sdeditor.cpp||In member function ‘virtual bool SDEditor::open(void*)’:|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|111|error: ‘kDelay’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|118|error: ‘kFeedBack’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|125|error: ‘kOut’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp||In member function ‘virtual void SDEditor::setParameter(VstInt32, float)’:|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|196|error: ‘kDelay’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|203|error: ‘kFeedBack’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|210|error: ‘kOut’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp||In member function ‘virtual void SDEditor::valueChanged(VSTGUI::CDrawContext*, VSTGUI::CControl*)’:|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|225|error: ‘kDelay’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|226|error: ‘kFeedBack’ was not declared in this scope|
    F:\Pro\VST\surrounddelay\sdeditor.cpp|227|error: ‘kOut’ was not declared in this scope|
    ||=== Build finished: 10 errors, 0 warnings ===|

    I ensured that adelay.h does exist in the surrounddelay directory (besides sdeditor.cpp), so I don’t understand why the first error occurs. Can anyone help me? Thank you by advance!

    • Julien
      August 24, 2010 at 07:56

      Hello,

      I figured out how to get rid off my problem: instead of copying the files surrounddelay.cpp, surrounddelay.h etc. to the project directory, I left them in their original directory and added them in place… the file paths are now correct and the build can be done. 🙂

  6. John
    September 14, 2010 at 22:18

    This isn’t working for me at all. I’m following the steps to the letter, but it won’t build. When it comes to the final step, it wont let me add the def.file under ‘other linker options’ its just blank.

  7. John
    September 15, 2010 at 15:42

    Ok I got it working, turns out code::blocks wasn’t installed correctly.

  8. Miguel
    October 10, 2010 at 22:30

    i take out the VST 3 SDK and in step 5 of AGAin i can´t find “C:\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def” the vstplug.def to build

  9. Sam D. Gwilliam
    July 7, 2011 at 08:35

    I should add that you need to set Dynamic Link Library for the build target on both debug AND release configurations. That threw me for a few minutes…

  10. Sam D. Gwilliam
    July 7, 2011 at 09:07

    Also, Cubase refused to run ADelay because libgcc_s_dw2-1.dll was not found.

    After some investigation, I discovered that adding the following to the Linker Settings (underneath “-def C:\dev\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def”) solved this:

    -static-libgcc -static-libstdc++

  11. Sam D. Gwilliam
    July 7, 2011 at 09:52

    When I tried to build Surround Delay, I got a load of linker errors. When (again) I found the solution on another site (add “-lole32 -lkernel32 -lgdi32 -luuid -luser32” to the linker switches), my next problem was that the plugin’s editor in Cubase was completely blank.

    Either I’ve screwed up massively or this tutorial is incomplete – because now I’ve hit a massive wall that I can’t see any way around and my enthusiasm is starting to wane pretty quickly…

    • Joris G
      January 14, 2012 at 15:46

      I had the same problem, this solved it for me:
      in vstplugmain.cpp add
      extern “c”
      before lines 46, 48 and 59. So
      VST_EXPORT AEffect* main_macho …
      VST_EXPORT AEffect* MAIN …
      BOOL WINAPI DllMain …
      becomes
      extern “C” VST_EXPORT AEffect* main_macho …
      extern “C” VST_EXPORT AEffect* MAIN …
      extern “C” BOOL WINAPI DllMain …
      It took me long to discover :p hope it helps

  12. Eddie P
    May 1, 2012 at 16:41

    Hi All,
    This site Rocks!!!!. I’m new to C++ just begenning I’m having trouble with the surroundsound delay were do i get the files that are stated in step 6. Mabe I over looked them but cant seem to find the when i get to adding them to Link Libraries. Thanx

  1. No trackbacks yet.

Leave a comment