Creating Windows VST 2.4 Plugin using MinGW

Creating VST Plug-ins with MinGW
This HOWTO is based on MSYS / MinGW. It assumes VST SDK version 2.4, but should be easily changed for other versions.

Prerequisites

 * MSYS / MinGW
 * Download VST SDK from Steinberg's homepage / Company / 3rd Party Developers / VST Audio Plug-Ins SDK
 * Some kind of VST host, for example Hermann Seib's great VSTHost or Ableton Live

Preparations
|- PLUGINNAME/ `- vstsdk2.4/ |- artwork |- etc.
 * create directory 'PLUGINNAME' (just make up your own name) somewhere
 * unpack VST SDK in the same directory as 'PLUGINNAME', you should end up with a structure like this:

Coding
LIBRARY    PLUGINNAME DESCRIPTION 'my first VST plugin' EXPORTS    main=VSTPluginMain
 * create cpp program 'PLUGINNAME.cpp', you could base it on vstsdk2.4/public.sdk/samples/vst2.x/again/source/again.cpp
 * create header file 'PLUGINNAME.h', you could base it on vstsdk2.4/public.sdk/samples/vst2.x/again/source/again.h
 * create file 'PLUGINNAME.def':

Building
 VSTSDKDIR = ../vstsdk2.4
 * create file 'Makefile' (if you copy-paste this Makefile, please ensure that all indentations are converted to TABs, otherwise make won't understand anything):
 * 1) change this to the location of your unpacked VST SDK:

CPP      = g++.exe OBJ      = PLUGINNAME.o $(VSTSDKDIR)/public.sdk/source/vst2.x/vstplugmain.o $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffect.o $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffectx.o LIBS      = -L. --add-stdcall-alias -lole32 -lkernel32 -lgdi32 -luuid -luser32 -mwindows --no-export-all-symbols --def PLUGINNAME.def CXXINCS  = -I"$(VSTSDKDIR)/pluginterfaces/vst2.x" -I"$(VSTSDKDIR)/public.sdk/source/vst2.x" -I"$(VSTSDKDIR)" -I"$(VSTSDKDIR)/vstgui.sf/vstgui" -I. BIN      = PLUGINNAME.dll CXXFLAGS = $(CXXINCS) -DBUILDING_DLL=1 -mwindows -O3 RM       = rm -f

.PHONY: all clean

all: PLUGINNAME.dll

clean: ${RM} $(OBJ) $(BIN)

DLLWRAP  = dllwrap.exe DEFFILE  = libPLUGINNAME.def STATICLIB = libPLUGINNAME.a

$(BIN): $(OBJ) $(DLLWRAP) --output-def $(DEFFILE) --driver-name c++ --implib $(STATICLIB) $(OBJ) $(LIBS) -o $(BIN)

PLUGINNAME.o: PLUGINNAME.cpp $(CPP) -c PLUGINNAME.cpp -o PLUGINNAME.o $(CXXFLAGS)

$(VSTSDKDIR)/public.sdk/source/vst2.x/vstplugmain.o: $(VSTSDKDIR)/public.sdk/source/vst2.x/vstplugmain.cpp $(CPP) -c $(VSTSDKDIR)/public.sdk/source/vst2.x/vstplugmain.cpp -o $(VSTSDKDIR)/public.sdk/source/vst2.x/vstplugmain.o $(CXXFLAGS)

$(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffect.o: $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffect.cpp $(CPP) -c $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffect.cpp -o $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffect.o $(CXXFLAGS)

$(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffectx.o: $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffectx.cpp $(CPP) -c $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffectx.cpp -o $(VSTSDKDIR)/public.sdk/source/vst2.x/audioeffectx.o $(CXXFLAGS)


 * In MSYS, cd to 'PLUGINNAME' and run 'make' - there will be warnings, but make should output a DLL, which is the actual VST Plug-in