Qt5 Windows静态链接错误

时间:2015-01-27 19:11:11

标签: c++ windows qt qmake static-linking

我正在尝试在Windows上构建Qt5应用程序,但我无法正确编译和链接它。
没有任何“直接”编译器或链接器错误,但是当我运行它时,Windows说缺少Qt5Core.dll。

事先我使用

静态编译Qt5
configure -static
mingw32-make

一切都很顺利。 这是我的项目文件(qmake):

TEMPLATE = app

QT += network widgets # core gui included by default

CONFIG += static c++11
DEFINES += VERSION=\\\"1.0\\\"

win32 {
    INCLUDEPATH += $$PWD/../../include
    LIBS += -L$$PWD/../../include/ -lluacppinterface -llua
}


SOURCES += main.cpp\
    Client.cpp\
    Updater.cpp\
    Header.cpp

HEADERS += Client.h\
    Updater.h\
    Header.h\

Qt Creator的编译器输出:

20:06:22: Running steps for project FireClient_qmake...
20:06:22: Starting: "C:\Qt\Tools\mingw491_32\bin\mingw32-make.exe" clean
C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile.Release clean
mingw32-make[1]: Entering directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
del release\moc_Client.cpp release\moc_Updater.cpp
del release\main.o release\Client.o release\Updater.o release\Header.o release\moc_Client.o release\moc_Updater.o
mingw32-make[1]: Leaving directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile.Debug clean
mingw32-make[1]: Entering directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
del debug\moc_Client.cpp debug\moc_Updater.cpp
Impossibile trovare C:\Users\User1\Qt_projs\build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release\debug\moc_Client.cpp
del debug\main.o debug\Client.o debug\Updater.o debug\Header.o debug\moc_Client.o debug\moc_Updater.o
Impossibile trovare C:\Users\User1\Qt_projs\build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release\debug\main.o
mingw32-make[1]: Leaving directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
20:06:22: The process "C:\Qt\Tools\mingw491_32\bin\mingw32-make.exe" exited normally.
20:06:22: Configuration unchanged, skipping qmake step.
20:06:22: Starting: "C:\Qt\Tools\mingw491_32\bin\mingw32-make.exe" -j9
C:/Qt/Tools/mingw491_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\main.o ..\FireClient_qmake\main.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\Client.o ..\FireClient_qmake\Client.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\Updater.o ..\FireClient_qmake\Updater.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\Header.o ..\FireClient_qmake\Header.cpp
C:\Qt\5.4\mingw491_32\bin\moc.exe -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -D__GNUC__ -DWIN32 -IC:/Qt/5.4/mingw491_32/mkspecs/win32-g++ -IC:/Users/User1/Qt_projs/FireClient_qmake -IC:/Users/User1/include -IC:/Qt/5.4/mingw491_32/include -IC:/Qt/5.4/mingw491_32/include/QtWidgets -IC:/Qt/5.4/mingw491_32/include/QtGui -IC:/Qt/5.4/mingw491_32/include/QtNetwork -IC:/Qt/5.4/mingw491_32/include/QtCore -I. ..\FireClient_qmake\Client.h -o release\moc_Client.cpp
C:\Qt\5.4\mingw491_32\bin\moc.exe -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -D__GNUC__ -DWIN32 -IC:/Qt/5.4/mingw491_32/mkspecs/win32-g++ -IC:/Users/User1/Qt_projs/FireClient_qmake -IC:/Users/User1/include -IC:/Qt/5.4/mingw491_32/include -IC:/Qt/5.4/mingw491_32/include/QtWidgets -IC:/Qt/5.4/mingw491_32/include/QtGui -IC:/Qt/5.4/mingw491_32/include/QtNetwork -IC:/Qt/5.4/mingw491_32/include/QtCore -I. ..\FireClient_qmake\Updater.h -o release\moc_Updater.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\moc_Updater.o release\moc_Updater.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DVERSION=\"1.0\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\FireClient_qmake -I"..\..\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtWidgets" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtGui" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtNetwork" -I"..\..\..\..\Qt\5.4\mingw491_32\include\QtCore" -I"release" -I"." -I"..\..\..\..\Qt\5.4\mingw491_32\mkspecs\win32-g++" -o release\moc_Client.o release\moc_Client.cpp
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\FireClient_qmake.exe release/main.o release/Client.o release/Updater.o release/Header.o release/moc_Client.o release/moc_Updater.o  -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -LC:/Qt/5.4/mingw491_32/lib -lqtmain -LC:\mingw491\mingw32\lib -LC:\Utils\icu32_53_1_mingw482\lib -LC:\utils\postgresql\pgsql\lib -LC:\utils\mysql\mysql\lib -LC:\opensll\lib -lshell32 -LC:\Qt\5.4\mingw491_32/lib -LC:/Users/User1/Qt_projs/FireClient_qmake/../../include/ -lluacppinterface -llua -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Core 
mingw32-make[1]: Leaving directory 'C:/Users/User1/Qt_projs/build-FireClient_qmake-Desktop_Qt_5_4_0_MinGW_32bit-Release'
20:06:30: The process "C:\Qt\Tools\mingw491_32\bin\mingw32-make.exe" exited normally.
20:06:30: Elapsed time: 00:08.

但是,Windows和Dependency Walker都说我的应用程序依赖于Qt5Core.dll和其他动态 Qt库。为什么不用qmake链接Qt静态库呢?

1 个答案:

答案 0 :(得分:0)

解决了,Qt创作者套件指向了这个qmake的动态版本。