提问人:John Smith 提问时间:11/17/2023 最后编辑:John Smith 更新时间:11/20/2023 访问量:42
在Qt上构建静态程序
Building a static program on Qt
问:
我已经在 Windows 上构建了 qt-6.6-static,我想构建一两个静态项目。我试图构建一个示例程序“Scenegraph”,但它失败了并显示错误消息。
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Qt/6.6.0-static/plugins/networkinformation/libqnetworklistmanager.a(qnetworklistmanagerevents.cpp.obj):qnetworklistmanagerevents.cpp:(.text$_ZN25QNetworkListManagerEvents24checkBehindCaptivePortalEv+0x82): undefined reference to `__imp_VariantInit'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Qt/6.6.0-static/plugins/networkinformation/libqnetworklistmanager.a(qnetworklistmanagerevents.cpp.obj):qnetworklistmanagerevents.cpp:(.text$_ZN25QNetworkListManagerEvents24checkBehindCaptivePortalEv+0x98): undefined reference to `__imp_VariantClear'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Qt/6.6.0-static/plugins/networkinformation/libqnetworklistmanager.a(qnetworklistmanagerevents.cpp.obj):qnetworklistmanagerevents.cpp:(.text$_ZN25QNetworkListManagerEvents24checkBehindCaptivePortalEv+0x1d9): undefined reference to `__imp_VariantClear'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Qt/6.6.0-static/plugins/networkinformation/libqnetworklistmanager.a(qnetworklistmanagerevents.cpp.obj):qnetworklistmanagerevents.cpp:(.text$_ZN25QNetworkListManagerEvents24checkBehindCaptivePortalEv+0x24d): undefined reference to `__imp_VariantClear'
collect2.exe: error: ld returned 1 exit status
我使用的编译器是 gcc 13.2.0
显然,这表明我应该链接到oleaut32.lib,但qt文件已经这样做了。在调试模式下测试了oleaut库,它似乎正在工作。
QT += quick
QT += opengl
CONFIG += c++2a
CONFIG += static
QMAKE_CXXFLAGS += -std=c++2a
LIBS += -lgmp
SOURCES += \
Squircle.cpp \
glrenderer.cpp \
main.cpp \
RESOURCES += \
qml.qrc
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
Squircle.h \
glrenderer.h \
DISTFILES += main.qml
还有其他人为此苦苦挣扎吗?除了“使用动态构建”之外,还有其他解决方案吗?
由于评论而添加了编辑
我忘了提到我尝试添加链接 LIBS +=-loleaut32 仍然出现相同的错误。
此外,这是一些编译输出。所以可以肯定的是,链接已经存在。
libqwindows.a -ldwmapi -limm32 -loleaut32 -lsetupapi -lshlwapi -lwinspool
lib/libQt6Network.a -lbrotlidec -lbrotlicommon
答: 暂无答案
评论