[英]Unresolved external symbol, cannot figure out why
我有兩個文件讓我很傷心: camAVTEx.h
和camAVTEx.cpp
。 這是兩個文件的常規設置:
//.h////////////////////////////////////////////////
/*
#includes to some other files
*/
class camera_avtcam_ex_t : public camera_t
{
public:
camera_avtcam_ex_t();
virtual ~camera_avtcam_ex_t();
private:
//some members
public:
//some methods
};
void GlobalShutdownVimbaSystem();
//.cpp/////////////////////////////////////////////
#include "StdAfx.h"
#include "camAVTEx.h"
//some other #includes
camera_avtcam_ex_t::camera_avtcam_ex_t()
{
}
//rest of the class' functions
void GlobalShutdownVimbaSystem()
{
//implememtation
}
然后,在另一個目錄中的文件中,對.h文件的確切位置執行#include並嘗試使用該類:
//otherfile.cpp
#include "..\..\src\HardSupport\Camera.h"
//this is the base camera class (camera_t)
#include "..\..\src\HardControl\camAVTEx.h"
//this is indeed where both the .h and .cpp files are located
void InitCam
{
camera_t* maincam = new camera_avtcam_ex_t();
}
void OnExit()
{
GlobalShutdownVimbaSystem();
}
編譯時,出現以下錯誤:
8> otherfile.obj:錯誤LNK2001:未解決的外部符號“ public:__cdecl camera_avtcam_ex_t :: camera_avtcam_ex_t(void)”(?? 0camera_avtcam_ex_t @@ QEAA @ XZ)
8> otherfile.obj:錯誤LNK2001:無法解析的外部符號“ void __cdecl GlobalShutdownVimbaSystem(void)”(?GlobalShutdownVimbaSystem @@ YAXXZ)
8> .... \\ bin \\ x64 \\ Release \\ otherfile.exe:致命錯誤LNK1120:2個未解析的外部組件
我一生無法弄清為什么找不到這兩個功能的實現。
因此,我想我的問題很明顯:為什么會出現這些錯誤?需要進行哪些更改以解決這些錯誤?
無論您如何看待,您都將遇到以下錯誤: unresolved external symbol "public: __cdecl camera_avtcam_ex_t::camera_avtcam_ex_t(void)" (??0camera_avtcam_ex_t@@QEAA@XZ)
表示編譯器知道符號camera_avtcam_ex_t::camera_avtcam_ex_
)類構造函數),因為他在camAVTEx.h
文件中看到了它的聲明,但是哈拉,它找不到(=解決)該符號的實現(簡而言之,代碼)。
通常由於幾種可能的原因而發生這種情況:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.