我有两个文件让我很伤心: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:未解析的外部符号“公共:__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 externals
我一生都无法弄清楚为什么它找不到这两个功能的实现。
所以我想我的问题很明显:为什么我会收到这些错误,我需要改变什么来修复它们?