[英]Unresolved external symbol, cannot figure out why
I have two files that are causing me a lot of grief: camAVTEx.h
and camAVTEx.cpp
. 我有两个文件让我很伤心:
camAVTEx.h
和camAVTEx.cpp
。 Here is the general setup for the two files: 这是两个文件的常规设置:
//.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
}
Then, in a file in a different directory, I do a #include to the exact location of the .h file and try to use the class: 然后,在另一个目录中的文件中,对.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();
}
When I compile, I get the following errors: 编译时,出现以下错误:
8>otherfile.obj : error LNK2001: unresolved external symbol "public: __cdecl camera_avtcam_ex_t::camera_avtcam_ex_t(void)" (??0camera_avtcam_ex_t@@QEAA@XZ)
8> otherfile.obj:错误LNK2001:未解决的外部符号“ public:__cdecl camera_avtcam_ex_t :: camera_avtcam_ex_t(void)”(?? 0camera_avtcam_ex_t @@ QEAA @ XZ)
8>otherfile.obj : error LNK2001: unresolved external symbol "void __cdecl GlobalShutdownVimbaSystem(void)" (?GlobalShutdownVimbaSystem@@YAXXZ)
8> otherfile.obj:错误LNK2001:无法解析的外部符号“ void __cdecl GlobalShutdownVimbaSystem(void)”(?GlobalShutdownVimbaSystem @@ YAXXZ)
8>....\\bin\\x64\\Release\\otherfile.exe : fatal error LNK1120: 2 unresolved externals
8> .... \\ bin \\ x64 \\ Release \\ otherfile.exe:致命错误LNK1120:2个未解析的外部组件
I cannot for the life of me figure out why it can't find the implementations for these two functions. 我一生无法弄清为什么找不到这两个功能的实现。
So I guess my question is fairly obvious: Why am I getting these errors and what do I need to change to fix them? 因此,我想我的问题很明显:为什么会出现这些错误?需要进行哪些更改以解决这些错误?
Whatever how you look at it, the error you have : unresolved external symbol "public: __cdecl camera_avtcam_ex_t::camera_avtcam_ex_t(void)" (??0camera_avtcam_ex_t@@QEAA@XZ)
means that the compiler knows the symbol camera_avtcam_ex_t::camera_avtcam_ex_
(that's the class constructor) since he saw its declaration in the camAVTEx.h
file but halas, it can't find (= resolve) the implementation of this symbol (in short, the code). 无论您如何看待,您都将遇到以下错误:
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
文件中看到了它的声明,但是哈拉,它找不到(=解决)该符号的实现(简而言之,代码)。
This usually happen because of several possible causes : 通常由于几种可能的原因而发生这种情况:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.