LNK2019在简单类中出错,看不出原因
LNK2019 error in simple class, cannot see why
我有以下类,它不会针对未解决的符号问题LNK2019进行编译。我看到了另一个似乎是类似问题的线程,但我不明白为什么我的线程没有链接,因为它要简单得多,而且似乎是一个标准实现。无论如何谢谢
// windowLevel.h header file for the class. Error is related to not resolving the constructor
window level.h:
#ifndef WINDOWLEVEL_H
#define WINDOWLEVEL_H
class windowLevel
{
public:
windowLevel();
void setWindow(unsigned int window){m_window = window;} // setters
void setLevel(unsigned int level){m_level = level;}
unsigned int window(){return m_window;} // getters
unsigned int level(){return m_level;}
private:
unsigned int m_window;
unsigned int m_level;
unsigned const int m_level_max = 255;
unsigned const int m_level_min = 0;
unsigned const int m_window_max = 255;
unsigned const int m_window_min = 0;
};
#endif // WINDOWLEVEL_H
// windowlevel.cpp class implementation file
windowlevel.cpp:
#include "windowlevel.h"
windowLevel::windowLevel()
{
}
// main.cpp main function
main.cpp:
#include <QCoreApplication>
#include <iostream>
#include "windowlevel.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug("Starting window level");
windowLevel win; // instantiate a windowlevel object
qDebug("Done!");
return a.exec();
}
无论何时在头(.h)文件中声明方法,但没有在代码(.cpp)文件中实现它们,都会得到未解析的外部。这是指编译器看到方法签名,但无法将其与实际代码体匹配。
当引用库时,头中的声明被映射到对外部dll的调用,因此使用了"外部"一词——它们并不总是映射到您自己的代码。这意味着,如果您包含了头文件,但未能正确引用这些头文件引用的库,则也可能出现此错误
相关文章:
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- C++驱动程序看不到头文件
- 请解释字谜的代码,我看不懂计数器数组,每个值已经是0
- 在头文件中定义变量不会出错
- 如何删除已输入的书以及如何使标题,语言和名称在上面放置空格不会出错?
- 看不到文件'SDL2.lib'
- WSL 看不到环境变量
- 为什么我的 FreeRTOS 任务看不到类成员?
- C++:处理错误,看不懂我的错误
- Google Colab 看不到 .so 文件
- 从DLL导出函数,LoadLibrary()需要用TEXT转换的字符串才能编译而不会出错
- 派生类看不到基类成员
- 为什么我看不到字符串?
- 为什么在定义类之前声明类的对象会在友元类中给出错误,而在友元函数中不会出错
- 看不出为什么这是段错误
- 编译器说对象是常量,我看不出如何
- 链接错误,我看不出为什么我会收到它
- 计时器没有运行,看不出为什么不-C++
- LNK2019在简单类中出错,看不出原因
- C++仍然在寻找 .lib 文件,但我看不出为什么