Windows下MinGW编译静态Qt I 之实践
来源:互联网 发布:马步 骑士巡游 算法 编辑:程序博客网 时间:2024/05/08 19:31
文件夹结构
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分。
0 0
- Windows下MinGW编译静态Qt I 之实践
- Windows下MinGW编译静态Qt5 I
- Windows下Qt4.8.5 + mingw静态编译
- 在windows下用Qt creator + mingw编译protobuf源码生成静态链接库的方法
- 在Windows 10下使用MinGW静态编译Qt 5.9.1的详细过程(Ver 17.0819)
- windows下 Qt 静态编译
- windows下 Qt 静态编译
- windows下 Qt 静态编译
- windows下 Qt 静态编译
- 在Windows下使用MinGW静态编译Assimp
- windows下msvc/mingw静态编译 lmdb的CMakeLists.txt
- Windows下使用CMake+MinGW静态编译发布.exe程序
- QT(MinGW)静态库+Opencv静态编译
- 在Windows环境下使用MinGW编译Qt 4.8.6
- Windows下为使用Mingw环境的Qt编译opencv
- Windows下编译静态Qt程序
- Qt:Windows平台下的静态编译
- Windows下Qt静态编译全解
- animation的XML相关配置
- ios开发系列--通知与消息机制
- js+css实现返回顶部功能
- STL 容器的常用操作
- 利用数据库自定义并发 bunket 功能
- Windows下MinGW编译静态Qt I 之实践
- docker web 管理套件 dockerui
- 使用Notepad++的XML Tools插件格式化XML文件
- Chrome插件开发实例 – 时间通知(notifications)
- 小强的HTML5移动开发之路(19)——HTML5 Local Storage(本地存储)
- js中substr,substring,indexOf,lastIndexOf的用法小结
- MySQL必知必会笔记(五)插入数据 创建和操纵表
- 获取android 设备的cpu gpu信息 mac地址
- [软考]之树和二叉树