Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#----------------------------------------------------------------------------- # # Copyright (c) 2013, Thierry Lelegard # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF # THE POSSIBILITY OF SUCH DAMAGE. # #----------------------------------------------------------------------------- <# .SYNOPSIS Build a static version of Qt for Windows. .DESCRIPTION This scripts downloads Qt source code, compiles and installs a static version of Qt. It assumes that a prebuilt Qt / MinGW environment is already installed, typically in C:\Qt. This prebuilt environment uses shared libraries. It is supposed to remain the main development environment for Qt. This script adds a static version of the Qt libraries in order to allow the construction of standalone and self-sufficient executable. This script is typically run from the Windows Explorer. Requirements: - Windows PowerShell 3.0 or higher. - 7-zip. .PARAMETER QtSrcUrl URL of the Qt source file archive. By default, use the latest identified version. .PARAMETER QtStaticDir Root directory where the static versions of Qt are installed. By default, use C:\Qt\Static. .PARAMETER QtVersion The Qt version. By default, this script tries to extract the version number from the Qt source file name. .PARAMETER MingwDir Root directory of the MinGW prebuilt environment. By default, use the version which was installed by the prebuilt Qt environment. .PARAMETER NoPause Do not wait for the user to press <enter> at end of execution. By default, execute a "pause" instruction at the end of execution, which is useful when the script was run from Windows Explorer. #> [CmdletBinding()] param( $QtSrcUrl = "F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1.tar", $QtStaticDir = "F:\Qt\Static-OpenSSL-Linked", $QtVersion = "", $arch = "32", $MingwDir = "", $threads = "16", $OPENSSL_HOME = "C:\OpenSSL\OpenSSL-Win$($arch)", [switch]$NoPause = $false ) # PowerShell execution policy. Set-StrictMode -Version 3 #----------------------------------------------------------------------------- # Main code #----------------------------------------------------------------------------- function Main { # Check that 7zip is installed. We use it to expand the downloaded archive. [void] (Get-7zip) # 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)_x$($arch)" # 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 F:\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])) $MingwDir = $MingwDir.Substring(0, $MingwDir.Length - 2) $MingwDir += $arch } 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)" # Expand archives if not yet done Expand-Archive $QtStaticDir\src\$QtSrcFileName $QtStaticDir\src $QtSrcDir # Patch Qt's mkspecs for static build. $File = "$QtSrcDir\qtbase\mkspecs\win32-g++\qmake.conf" if (-not (Select-String -Quiet -SimpleMatch -CaseSensitive "# [QT-STATIC-PATCH]" $File)) { Write-Output "Patching $File ..." Copy-Item $File "$File.orig" @" # [QT-STATIC-PATCH] QMAKE_LFLAGS += -static -static-libgcc QMAKE_CFLAGS_RELEASE -= -O2 QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer DEFINES += QT_STATIC_BUILD "@ | Out-File -Append $File -Encoding Ascii } # Set a clean path including MinGW. $env:Path = "$MingwDir\bin;$MingwDir\opt\bin;$env:SystemRoot\system32;$env:SystemRoot" # Force English locale to avoid weird effects of tools localization. $env:LANG = "en" # Set environment variable QT_INSTALL_PREFIX. Documentation says it should be # used by configure as prefix but this does not seem to work. So, we will # also specify -prefix option in configure. $env:QT_INSTALL_PREFIX = $QtDir # Configure, compile and install Qt. Push-Location $QtSrcDir set OPENSSL_LIBS="-lssl -lcrypto" cmd /c "configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir ` -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -openssl-linked -I $($OPENSSL_HOME)\include -L$($OPENSSL_HOME)\lib\MinGW ` -opensource -confirm-license ` -make libs -nomake tools -nomake examples -nomake tests" cmd /c "mingw32-make -k -j$($threads)" mingw32-make -k install Pop-Location # Patch Qt's installed mkspecs for static build of application. $File = "$QtDir\mkspecs\win32-g++\qmake.conf" @" CONFIG += static "@ | Out-File -Append $File -Encoding Ascii Exit-Script } #----------------------------------------------------------------------------- # A function to exit this script. The Message parameter is used on error. #----------------------------------------------------------------------------- function Exit-Script ([string]$Message = "") { $Code = 0 if ($Message -ne "") { Write-Output "ERROR: $Message" $Code = 1 } if (-not $NoPause) { pause } exit $Code } #----------------------------------------------------------------------------- # Silently create a directory. #----------------------------------------------------------------------------- function Create-Directory ([string]$Directory) { [void] (New-Item -Path $Directory -ItemType "directory" -Force) } #----------------------------------------------------------------------------- # Download a file if not yet present. # Warning: If file is present but incomplete, do not download it again. #----------------------------------------------------------------------------- function Download-File ([string]$Url, [string]$OutputFile) { $FileName = Split-Path $Url -Leaf if (-not (Test-Path $OutputFile)) { # Local file not present, start download. Write-Output "Downloading $Url ..." try { $webclient = New-Object System.Net.WebClient $webclient.DownloadFile($Url, $OutputFile) } catch { # Display exception. $_ # Delete partial file, if any. if (Test-Path $OutputFile) { Remove-Item -Force $OutputFile } # Abort Exit-Script "Error downloading $FileName" } # Check that the file is present. if (-not (Test-Path $OutputFile)) { Exit-Script "Error downloading $FileName" } } } #----------------------------------------------------------------------------- # Get path name of 7zip, abort if not found. #----------------------------------------------------------------------------- function Get-7zip { $Exe = "C:\Program Files\7-Zip\7z.exe" if (-not (Test-Path $Exe)) { $Exe = "C:\Program Files (x86)\7-Zip\7z.exe" } if (-not (Test-Path $Exe)) { Exit-Script "7-zip not found, install it first, see http://www.7-zip.org/" } $Exe } #----------------------------------------------------------------------------- # Expand an archive file if not yet done. #----------------------------------------------------------------------------- function Expand-Archive ([string]$ZipFile, [string]$OutDir, [string]$CheckFile) { # Check presence of expected expanded file or directory. if (-not (Test-Path $CheckFile)) { Write-Output "Expanding $ZipFile ..." & (Get-7zip) x $ZipFile "-o$OutDir" | Select-String -Pattern "^Extracting " -CaseSensitive -NotMatch if (-not (Test-Path $CheckFile)) { Exit-Script "Error expanding $ZipFile, $OutDir\$CheckFile not found" } } } #----------------------------------------------------------------------------- # Execute main code. #----------------------------------------------------------------------------- . Main
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
FED RESPONSE TEMPLATES: FED HTML Review Feedb...
8 hours ago | 0.79 KB
disable email per category (not fully tested)
11 hours ago | 0.82 KB
Neuromancer — The Construct Cut (Complete Una...
17 hours ago | 3.30 KB
GLUC6
17 hours ago | 1.56 KB
Mapscan v1.0 - Archeagus Grey Hack Series, Ep...
JavaScript | 22 hours ago | 3.33 KB
Untitled
23 hours ago | 17.15 KB
gpt2
Go | 1 day ago | 2.79 KB
gpt
GetText | 1 day ago | 1.07 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!