我試圖在Visual Studio中創建一個簡單的C++項目2015年錯誤解析外部符號
Peakdetector.h
#ifndef PEAKDETECTOR_H
#define PEAKDETECTOR_H
//-------------------------------------------------------
#ifdef DLL_BUILD_SETUP
#ifdef Q_OS_LINUX
#define DLLSPEC __attribute__((visibility("default")))
#else
#define DLLSPEC __declspec(dllexport)
#endif
#else
#ifdef Q_OS_LINUX
#define DLLSPEC
#else
#define DLLSPEC __declspec(dllimport)
#endif
#endif
namespace vpg {
#ifndef VPG_BUILD_FROM_SOURCE
class DLLSPEC PeakDetector
#else
class PeakDetector
#endif
private:
int __seek(int d) const;
double __getDuration(int start, int stop);
}
inline int PeakDetector::__seek(int d) const
{
return ((m_intervalslength + (d % m_intervalslength)) % m_intervalslength);
}
#endif
PeakDetector.cpp
#include "stdafx.h"
#include "peakdetector.h"
namespace vpg {
void PeakDetector::__updateInterval(double _duration)
{
//other stuff
}
}
當我嘗試運行此應用程序我得到錯誤
LNK2019函數「private:void」中引用的無法解析的外部符號「__declspec(dllimport)private:int __cdecl vpg :: PeakDetector :: __ seek(int)const」(__imp _?_ seek @ PeakDetector @ vpg @@ AEBAHH @ Z) __cdecl VPG :: PeakDetector :: __ updateInterval(雙)」(?__ updateInterval @ PeakDetector @ VPG @@ AEAAXN @ Z)MyCustomProject
我是新來這一點,想不通爲什麼我有這個error.I已只是複製粘貼這個代碼從一個例子。請讓我知道如果我缺少任何代碼。另外我沒有任何.lib文件。
C++區分大小寫。 –
@NeilButterworth非常感謝你。就像我說的,我對此很新。我應該在這裏改變什麼?它是'class peakDetector {'?? – Rohit
@Rohit類名「class PeakDetector」 – Naidu