I'm writing a VST in C++ currently, and I ran into an issue. I've been surfing the web and StackOverflow for a while now and I'm stuck. Two files are giving me the issue, SynthesizerTwo.h
and SynthesizerTwo.cpp
.
The error I get is:
'kNumPrograms': undeclared identifier [in SynthesizerTwo.h]
I have a const int called kNumPrograms that is declared like this in SynthesizerTwo.cpp:
#include "SynthesizerTwo.h"
#pragma warning( suppress : 4101 4129 )
#include "IPlug_include_in_plug_src.h"
#include "IControl.h"
#include "resource.h"
const int kNumPrograms = 1; //Original Declaration
enum EParams
{
kNumParams
};
Then, in SynthesizerTwo.h
, it is used in the class SynthesizerTwo
like this:
#ifndef __SYNTHESIZERTWO__
#define __SYNTHESIZERTWO__
#include "Oscillator.h"
#include "MIDIReceiver.h"
#pragma warning( suppress : 4101 4129 )
#include "IPlug_include_in_plug_hdr.h"
class SynthesizerTwo : public IPlug
{
public:
SynthesizerTwo(IPlugInstanceInfo instanceInfo);
~SynthesizerTwo();
//const int kNumPrograms = 5;
void Reset();
void OnParamChange(int paramIdx);
void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);
// to receive MIDI messages:
void ProcessMidiMsg(IMidiMsg* pMsg);
private:
double mFrequency;
void SynthesizerTwo::CreatePresets() {
MakeDefaultPreset((char*)"-", kNumPrograms); //This is what gives me the error
}
Oscillator mOscillator;
MIDIReceiver mMIDIReceiver;
};
#endif
I've tried putting the declaration into the .h file, but then I get an LNK2019 linker error. I've also tried using an extern
before the declaration in both the .cpp.
and the .h
.
I've tried putting the declaration outside the class in the .h
, in the public section, and in the private section. I've also tried moving the declaration in the .cpp
above the .h
#include
but I still get errors.
Linker error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: void __thiscall MIDIReceiver::advance(void)" (?advance@MIDIReceiver@@QAEXXZ) referenced in function "public: virtual void __thiscall SynthesizerTwo::ProcessDoubleReplacing(double * *,double * *,int)" (?ProcessDoubleReplacing@SynthesizerTwo@@UAEXPAPAN0H@Z) SynthesizerTwo-vst2 C:\wdl-ol\IPlugExamples\SynthesizerTwo\SynthesizerTwo.obj 1
Any help would be much appreciated.