xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.97k stars 780 forks source link

error LNK2019: 无法解析的外部符号 #5743

Closed ysx1993 closed 6 hours ago

ysx1993 commented 8 hours ago

Xmake 版本

2.9.5

操作系统版本和架构

Windows11, Qt5.15.2, msvc编译器

描述问题

您好,我在使用xmake改造我的项目时遇到了一个问题需要请教一下,如图所示,我有一个主程序引用了一个第三方热键库,这个热键库以静态库的方式已编译成功,但编译主程序时出现以下报错:

image

刚学xmake,请问大概是哪个地方写法有问题?谢谢!

期待的结果

期望编译无误

工程配置

测试程序: target("hotkeytest") add_rules("qt.widgetapp") -- add_rules("qt.console") add_files("*.cpp") -- add files with Q_OBJECT meta (only for qt.moc) -- qDebug以及std::cout打印开启 add_ldflags("/subsystem:console") -- 包含QHotkey库 add_deps("QHotkey")

QHotkey第三方库: target("QHotkey") add_rules("qt.static") add_headerfiles(".h") add_files(".h") if is_plat("macosx") then add_files("qhotkey_mac.cpp") elseif is_plat("windows") then add_files("qhotkey_win.cpp") else add_files("qhotkey_x11.cpp") end add_includedirs("..", {public = true}) add_frameworks("QtGui")

附加信息和错误日志

checking for Microsoft Visual Studio (x64) version ... 2019 checking for Microsoft C/C++ Compiler (x64) version ... 19.29.30153 checking for Qt SDK directory ... D:/Dev/Qt5.15.2-vs2019/5.15.2/msvc2019_64 checking for Qt SDK version ... 5.15.2 [ 90%]: linking.debug hotkeytest.exe error: main.cpp.obj : error LNK2019: 无法解析的外部符号 "public: cdecl QHotkey::QHotkey(class QObject *)" (??0QHotkey@@QEAA@PEAVQObject@@@Z),函数 main 中引用了该符号 main.cpp.obj : error LNK2019: 无法解析的外部符号 "public: virtual cdecl QHotkey::~QHotkey(void)" (??1QHotkey@@UEAA@XZ),函数 main 中引用了该符号 main.cpp.obj : error LNK2019: 无法解析的外部符号 "public: bool __cdecl QHotkey::setRegistered(bool)" (?setRegistered@QHotkey@@QEAA_N_N@Z),函数 main 中引用了该符号 build\windows\x64\debug\hotkeytest.exe : fatal error LNK1120: 3 个无法解析的外部命令

Issues-translate-bot commented 8 hours ago

Bot detected the issue body's language is not English, translate it automatically.


Title: error LNK2019: unresolved external symbol