着实折腾了很久~~,折腾过程就不说了,直接说结果吧


首先安装Qt VS Tools插件,然后随便建立一个工程~~~


1.常规->平台集 改为

Visual Studio 2013 - Windows XP (v120_xp)


此时应该尝试编译,运气好可能通过!!不能编译的,继续往下看!!


如果上面编译通过了,尝试运行时会出现以下错误:

---------------------------
QtGuiApplicationStatic
---------------------------
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "".

Reinstalling the application may fix this problem.
---------------------------
确定   
---------------------------


继续折腾!!查找资料~~


//main.cpp添加

#include <QtPlugin>

Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)


2.链接器->常规->附件目录 添加

$(QTDIR)\plugins\platforms


3.链接器->输入->附加依赖库 添加

Qt5PlatformSupport.lib
qwindows.lib


继续编译,发现一堆错误~~ 经过一番分析,得出以下依赖库结论

qtmain.lib
qtpcre.lib
qtharfbuzzng.lib
qtfreetype.lib
qwindows.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib


再次编译,顺利通过,拷贝到XP虚拟机,不需要任何依赖,顺利运行!


至此,静态编译告破!!!


写个代码试试:

QMessageBox::information(this, tr("飘云阁"), tr("安全论坛"));


发现是乱码~~~  解决方法:

#pragma execution_character_set("utf-8")



双击*.ui文件打开设计器,发现界面又是英文的~~(动态库版本的是中文),解决方法:

将D:\Qt\Qt5.7.0\5.7\msvc2013\bin\qt.conf  拷贝到 D:\Qt\Qt5.7.0\5.7\msvc2013_static\bin\qt.conf

你可能感兴趣的文章

评论区

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。