生成项目时出现链接器错误
Linker error when building project
当我尝试在Visual Studio 2010中构建项目时,出现以下错误:
1>WaveEditDoc.obj : error LNK2001: unresolved external symbol "public: static int CWaveEditView::selectionEnd" (?selectionEnd@CWaveEditView@@2HA)
1>WaveEditView.obj : error LNK2019: unresolved external symbol "public: static int CWaveEditView::selectionEnd" (?selectionEnd@CWaveEditView@@2HA) referenced in function "public: virtual void * __thiscall CWaveEditView::`scalar deleting destructor'(unsigned int)" (??_GCWaveEditView@@UAEPAXI@Z)
1>WaveEditDoc.obj : error LNK2001: unresolved external symbol "public: static int CWaveEditView::selectionStart" (?selectionStart@CWaveEditView@@2HA)
1>WaveEditView.obj : error LNK2019: unresolved external symbol "public: static int CWaveEditView::selectionStart" (?selectionStart@CWaveEditView@@2HA) referenced in function "public: virtual __thiscall CWaveEditView::~CWaveEditView(void)" (??1CWaveEditView@@UAE@XZ)
1>C:UsersaottingeDocumentsCS390CPPWaveEditDebugWaveEdit.exe : fatal error LNK1120: 2 unresolved externals
selectionStart
和selectionEnd
是在CWaveEditView中定义的,我正在尝试在WaveEditDoc类的函数中访问它们。 我没有收到编译器错误,所以我知道我正确地引用了所有内容。 以下是显然导致此问题的代码部分:
void CWaveEditDoc::OnToolsPlay()
{
// TODO: Add your command handler code here
if(CWaveEditView::selectionStart!=CWaveEditView::selectionEnd){
WaveFile * selection = new WaveFile(wave.numChannels, wave.sampleRate, wave.bitsPerSample);
int i = CWaveEditView::selectionStart;
while(i<=CWaveEditView::selectionEnd){
selection->add_sample(wave.get_sample(i));
}
selection->play();
delete selection;
}else{
wave.play();
}
}
您没有收到编译器错误的事实仅意味着编译器已经看到了 selectionStart 和 selectionEnd 的声明,并且所有类型都已检查
您收到链接器错误,因为没有可见的这些符号的实际定义。
显而易见的问题:selectionStart和selectionEnd的定义在哪里 - 您是否将Doc & View对象文件链接在一起,以便链接器可以将外部符号与其定义匹配?
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误