从入门到精通|基于CV-UNet Universal Matting镜像的抠图全流程
2026/1/20 2:36:59
从其他项目引入qcustomplot.h/cpp后,编译时报大量LNK2001元对象链接错误:
qcustomplot.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall QCPLayer::metaObject(void)const " qcustomplot.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall QCPLayer::qt_metacast(char const *)" ... (共100+个类似错误)Qt使用元对象编译器(MOC)处理包含Q_OBJECT宏的类。当MOC未运行时:
症状:出现QPrinter相关链接错误
解决方案:
Qt Project Settings→Qt Modulesprintsupport配置属性→链接器→输入→附加依赖项Qt5PrintSupport.lib症状:编译输出中没有"Moc’ing qcustomplot.h…"
解决方案:
qcustomplot.h编辑.vcxproj文件,将:
<ClIncludeInclude="qcustomplot.h"/>改为:
<QtMocInclude="qcustomplot.h"/>qcustomplot.h| 问题 | 症状 | 解决方案 |
|---|---|---|
| 缺少MOC | 元对象链接错误 | 改文件属性为"Qt MOC"或编辑.vcxproj |
| 缺少PrintSupport | QPrinter链接错误 | 添加printsupport模块和Qt5PrintSupport.lib |
| 配置不完整 | 各种奇怪错误 | 检查包含目录、预处理器定义、链接库 |