【发布时间】:2020-09-27 03:59:15
【问题描述】:
我使用以下指南在 Windows 中使用 MinGW 编译器静态编译了 Qt5.14.0:
编译qt后,使用qmake创建的项目是静态编译的,没有任何错误。但是定义为 cmake 的项目会出现以下错误:
qcoreapplication_win.cpp:-1: error: undefined reference to `GetFileVersionInfoSizeW@8'
qcoreapplication_win.cpp:-1: error: undefined reference to `GetFileVersionInfoW@16'
qcoreapplication_win.cpp:-1: error: undefined reference to `VerQueryValueW@16'
qglobal.cpp:-1: error: undefined reference to `_imp__WSACleanup@0'
qglobal.cpp:-1: error: undefined reference to `_imp__WSAStartup@8'
qglobal.cpp:-1: error: undefined reference to `_imp__WSACleanup@0'
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(untitled27 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5Core)
add_executable(untitled27
main.cpp
)
target_link_libraries(untitled27 Qt5::Core)
main.cpp
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
【问题讨论】:
-
请看我之前关于如何构建 qt-5.15.0 静态版本的回复:stackoverflow.com/questions/62180840/…
标签: windows qt cmake static mingw