我有兩個文件引起了我很多的難過: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
}
然後,在不同的目錄中的文件,我做的#include到的確切位置.h文件並嘗試使用該類:
//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:無法解析的外部符號 「公用:__cdecl camera_avtcam_ex_t :: camera_avtcam_ex_t(無效)」(?? 0camera_avtcam_ex_t @@ QEAA @XZ)
8> otherfile.obj:錯誤LNK2001:解析外部符號 「空隙__cdecl GlobalShutdownVimbaSystem(無效)」(GlobalShutdownVimbaSystem @@ YAXXZ)
8> .... \ BIN \ 64 \? Release \ otherfile.exe:致命錯誤LNK1120:2個未解決的外部事件
我不能爲了我的生活找出爲什麼它找不到這兩個函數的實現。
所以我想我的問題是相當明顯的:爲什麼我得到這些錯誤,我需要改變以解決它們?
你確定該文件訪問在你的程序中包含的文件?這可能是你的文件無法找到那些包含/ – 2013-05-13 13:22:26
相當明顯的可能性,但你確定'camAVTEx.cpp'已經編譯並且鏈接到你的'otherfile.cpp'文件嗎?你的構建系統是什麼? – Offirmo 2013-05-13 13:23:32
@ Need4Sleep我不明白它是如何訪問的 – xcdemon05 2013-05-13 13:24:48