Windows下MinGW编译静态Qt I 之实践
2015-09-24 15:46
585 查看
文件夹结构
Qt动态环境安装路径 D:\Qt\MinGW\Qt静态环境路径 D:\Qt\MinGW\Static
Qt源代码目录 D:\Qt\MinGW\Static\src\
//解压源代码到此目录下,长这个样子
修改脚本
function Main { # Check that 7zip is installed. We use it to expand the downloaded archive. #[void] (Get-7zip) #手动解压,跳过验证7-zip # Get Qt source file name from URL. $QtSrcFileName = Split-Path -Leaf $QtSrcUrl # If Qt version is not specified on the command line, try to extract the value. if (-not $QtVersion) { $QtVersion = $QtSrcFileName -replace "`.[^`.]*$",'' $QtVersion = $QtVersion -replace 'qt-','' $QtVersion = $QtVersion -replace 'everywhere-','' $QtVersion = $QtVersion -replace 'opensource-','' $QtVersion = $QtVersion -replace 'src-','' $QtVersion = $QtVersion -replace '-src','' } Write-Output "Building static Qt version $QtVersion" # Qt installation directory. $QtDir = "$QtStaticDir\$QtVersion" # Get MinGW root directory, if not specified on the command line. if (-not $MingwDir) { # Search all instances of gcc.exe from C:\Qt prebuilt environment. $GccList = @(Get-ChildItem -Path C:\Qt\*\Tools\mingw*\bin\gcc.exe | ForEach-Object FullName | Sort-Object) if ($GccList.Length -eq 0) { Exit-Script "MinGW environment not found, no Qt prebuilt version?" } $MingwDir = (Split-Path -Parent (Split-Path -Parent $GccList[$GccList.Length - 1])) } Write-Output "Using MinGW from $MingwDir" # Build the directory tree where the static version of Qt will be installed. #Create-Directory $QtStaticDir\src #已手动创建,且源代码已解压到此路径下 Create-Directory $QtDir # Download the Qt source package if not yet done. #Download-File $QtSrcUrl $QtStaticDir\src\$QtSrcFileName #跳过下载代码包 # Directory of expanded packages. #$QtSrcDir = "$QtStaticDir\src\$((Get-Item $QtStaticDir\src\$QtSrcFileName).BaseName)" $QtSrcDir = "$QtStaticDir\src\qt-everywhere-opensource-src-5.5.0" #手动指定源代码目录 # Expand archives if not yet done #Expand-Archive $QtStaticDir\src\$QtSrcFileName $QtStaticDir\src $QtSrcDir #跳过解压源代码包 ...以下略... }
执行脚本
在PowerShell中执行脚本,PS D:\Qt> .\windows-build-qt-static.ps1 -QtStaticDir 'D:\Qt\MinGW\Static' -QtVersion 'Qt5.5.0' -MingwDir 'D:\Qt\MinGW\Qt5.5.0\Tools\mingw492_32\' -QtStaticDir 'D:\Qt\MinGW\Static' #默认为c:\Qt\Static -QtVersion 'Qt5.5.0' #脚本解析为5.5.0,运行过程出现报错。手动指定版本号解决了。 -MingwDir 'D:\Qt\MinGW\Qt5.5.0\Tools\mingw492_32\' #若不指定,脚本会从默认安装路径找C:\Qt\*\Tools\mingw*\bin\gcc.exe
遇到的问题
PowerShell执行脚本提示“无法加载文件”Set-ExecutionPolicy RemoteSigned
参考powershell-无法加载文件,因为在此系统中禁止执行脚本。
附注
自行下载源代码并解压,修改后的脚本在我的机器上运行花了1小时45分。
相关文章推荐
- 搭建基于Mac 的QT IOS开发环境
- 大量的QT控件及示例发放
- QT经验(一)
- Qt5的QProcess类实现外部函数的调用,很简单!
- qt中如果用qDebug输出彩色调试信息
- QT中的信号与槽的相关知识
- QT 开发环境搭建
- QT相关内容的下载链接
- Qt中以固定格式写批量int型数据至文件之格式控制(数字对齐)
- GDAL Qt 开发
- QT中的foreach语句
- Windows下MinGW编译静态Qt5 I
- Qt信号与槽机制
- Linux系统下的OpenCV编译以及OpenCV的Qt上的使用
- OpenGL QT glViewport 函数的作用
- QT 笔记
- 基于Apollo代理服务器的MQTT推送平台搭建
- MQTT
- Qt 命令行编译
- Qt 对象树 <一>