Compiling OpenSSL with MinGW: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<textarea style='width:98%;' cols='90' rows='25' class='textarea' readonly="readonly"> | |||
[[Category:MinGW]]<br />[[Category:Windows]]<br />[[Category:Qt5]] | |||
== Compiling OpenSSL with MinGW or MinGW-w64 == | |||
Qt 5 / QtWebkit can make use of OpenSSL, which MinGW distributions do not ship. | |||
== Pre-built packages == | |||
The "Win32OpenSSL project&quot;:http://slproweb.com/products/Win32OpenSSL.html provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2008 runtime being installed. | |||
Inside [[MSYS2]] shell, pre-built openssl can be obtained from MSYS2 repo, with this command: pacman -S openssl | |||
== Compiling on your own == | |||
=== Requirements === | |||
* Either use MSYS, or use [[MSYS2]] : | |||
** MSYS shell command prompt (an sh shell + some UNIX tools, get it from http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download?use_mirror=garr. It's also an (optional) part of mingw.org installer). Install it in C:drive in "msys&quot; folder. | |||
** [[MSYS2]] shell command prompt, it can be obtained from https://msys2.github.io/ Install it in C:drive in "msys2&quot; folder. | |||
* Working MinGW, or MinGW-w64 toolchain: | |||
** Either get & load MinGW, or, get & load MinGW-w64 toolchains (from their respective project website), or, use "MinGW-w64&quot; toolchains from MSYS2 repo, inside the MSYS2-shell. | |||
** NOTE: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, when targeted for same platform/OS. If you are using MinGW-w64 based toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for main project & all sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components & main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from "MinGW-builds&quot;, then for all sub-components & main project, use same MinGW-builds toolchains. | |||
=== How to build === | |||
* Download latest+stable "OpenSSL&quot;:https://www.openssl.org/ (You must use HTTPS secure encrypted connection to obtain source file) from https://www.openssl.org/source (e.g. openssl-1.0.1c.tar.gz) | |||
* Either start MSYS-shell, or start MSYS2-shell: | |||
** Start a MSYS shell command prompt (C:.0\msys.bat) | |||
** Or, start MSYS2 shell command prompt (C:2\msys2_shell.bat) | |||
*** See inside this [[MSYS2]] page, how to prepare MSYS2 with build/compile related toolchains, tools & dependencies | |||
* Extract source tar.gz using MSYS tar or MSYS2 tar (and ignore the symlink warnings) | |||
** ''don't use 7zip or other apps, since they fail to set up any symlinks! tar will also complain about symlinks, but compilation will still succeed.'' | |||
* Unzip/decompress source:<br /><code><br />&#36; tar xvzf openssl-1.0.1c.tar.gz<br />&#36; cd openssl-1.0.1c<br /></code> | |||
* Check that gcc is in PATH, otherwise add it: change below command to match with your-side directory's exact name & letter-case & location: | |||
** If using MinGW-builds toolchain (which is usually located outside of MSYS or MSYS2), then execute this in MSYS or in MSYS2:<br /><code><br />&#36; export PATH="/c/Mingw-builds/bin:&#36;PATH&quot;<br /></code> | |||
** If using MSYS shell, and if you have installed MinGW toolchain into C:32 directory, then execute this:<br /><code><br />&#36; export PATH="/c/mingw32/bin:&#36;PATH&quot;<br /></code> | |||
** If using MSYS2 shell, execute this, if you are building for 32bit:<br /><code><br />&#36; export PATH="/c/msys2/mingw32/bin:&#36;PATH&quot;<br /></code> | |||
** If using MSYS2 shell, execute this, if you are building for 64bit:<br /><code><br />&#36; export PATH="/c/msys2/mingw64/bin:&#36;PATH&quot;<br /></code> | |||
* for MinGW (32 bit) do:<br /><code><br />&#36; ./Configure —prefix=&#36;PWD/dist no-idea no-mdc2 no-rc5 shared mingw<br /></code> | |||
* for MinGW-w64 do:<br /><code><br />&#36; ./Configure —prefix=&#36;PWD/dist no-idea no-mdc2 no-rc5 shared mingw64<br /></code> | |||
* Compile & install:<br /><code><br />&#36; make depend && make && make install<br /></code> | |||
== Errors == | |||
* If you run into<br /><code><br />perl asm/sha1-x86_64.pl mingw64 > sha1-x86_64.s<br />gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -D_WINDLL -DOPENSSL_PIC -DOPENSSL_TH<br />READS -D_MT -DDSO_WIN32 -DL_ENDIAN -O3 -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -DOPENSSL_IA<br />32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM <s>DSHA256_ASM</s><br />DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c -o sha1-x86_<br />64.o sha1-x86_64.s<br />sha1-x86_64.s: Assembler messages:<br />sha1-x86_64.s:1824: Warning: end of file not at end of a line; newline inserted<br />sha1-x86_64.s:2183: Error: number of operands mismatch for `rol'<br />make[2]: '''* [sha1-x86_64.o] Error 1<br />make[2]: Leaving directory `/d/dev/tmp/openssl-1.0.1c/crypto/sha'<br />make[1]:'''* [subdirs] Error 1<br />make[1]: Leaving directory `/d/dev/tmp/openssl-1.0.1c/crypto'<br />make: '''* [build_crypto] Error 1<br /></code> | |||
<br />''' check out http://openssl.6102.n7.nabble.com/Compile-error-with-MinGW-w64-td36657.html<br />'''* Use perl inside MSYS or inside MSYS2<br />'''* or change crypto/perlasm/x86_64-xlate.pl as mentioned in the e-mail thread. | |||
== Using it == | |||
* If you are using cmd.exe (Cmd-shell), then: add the bin, include, lib folders to your compilation environment:<br /><code><br />C:gt; set PATH=PATH;C:–1.0.1c\dist\bin<br />C:gt; set INCLUDE=INCLUDE;C:–1.0.1c\dist\include<br />C:gt; set LIB=LIB;C:–1.0.1c\dist\lib<br /></code> | |||
* If you are using MSYS2/MSYS-shell, then: add the bin, include, lib folders to your compilation environment:<br /><code><br />&#36; export PATH="&#36;PATH:/c/openssl-1.0.1c/dist/bin&quot;<br />&#36; export INCLUDE="&#36;INCLUDE:/c/openssl-1.0.1c/dist/include&quot;<br />&#36; export LIB="&#36;LIB:/c/openssl-1.0.1c/dist/lib&quot;<br /></code> | |||
When you now run Qt's configure.exe openssl should be detected, and Qt links against the libraries. |
Revision as of 13:02, 23 February 2015
<textarea style='width:98%;' cols='90' rows='25' class='textarea' readonly="readonly">
Compiling OpenSSL with MinGW or MinGW-w64
Qt 5 / QtWebkit can make use of OpenSSL, which MinGW distributions do not ship.
Pre-built packages
The "Win32OpenSSL project":http://slproweb.com/products/Win32OpenSSL.html provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2008 runtime being installed.
Inside MSYS2 shell, pre-built openssl can be obtained from MSYS2 repo, with this command: pacman -S openssl
Compiling on your own
Requirements
- Either use MSYS, or use MSYS2 :
- MSYS shell command prompt (an sh shell + some UNIX tools, get it from http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download?use_mirror=garr. It's also an (optional) part of mingw.org installer). Install it in C:drive in "msys" folder.
- MSYS2 shell command prompt, it can be obtained from https://msys2.github.io/ Install it in C:drive in "msys2" folder.
- Working MinGW, or MinGW-w64 toolchain:
- Either get & load MinGW, or, get & load MinGW-w64 toolchains (from their respective project website), or, use "MinGW-w64" toolchains from MSYS2 repo, inside the MSYS2-shell.
- NOTE: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, when targeted for same platform/OS. If you are using MinGW-w64 based toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for main project & all sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components & main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from "MinGW-builds", then for all sub-components & main project, use same MinGW-builds toolchains.
How to build
- Download latest+stable "OpenSSL":https://www.openssl.org/ (You must use HTTPS secure encrypted connection to obtain source file) from https://www.openssl.org/source (e.g. openssl-1.0.1c.tar.gz)
- Either start MSYS-shell, or start MSYS2-shell:
- Start a MSYS shell command prompt (C:.0\msys.bat)
- Or, start MSYS2 shell command prompt (C:2\msys2_shell.bat)
- See inside this MSYS2 page, how to prepare MSYS2 with build/compile related toolchains, tools & dependencies
- Extract source tar.gz using MSYS tar or MSYS2 tar (and ignore the symlink warnings)
- don't use 7zip or other apps, since they fail to set up any symlinks! tar will also complain about symlinks, but compilation will still succeed.
- Unzip/decompress source:
<br />&#36; tar xvzf openssl-1.0.1c.tar.gz<br />&#36; cd openssl-1.0.1c<br />
- Check that gcc is in PATH, otherwise add it: change below command to match with your-side directory's exact name & letter-case & location:
- If using MinGW-builds toolchain (which is usually located outside of MSYS or MSYS2), then execute this in MSYS or in MSYS2:
<br />&#36; export PATH="/c/Mingw-builds/bin:&#36;PATH&quot;<br />
- If using MSYS shell, and if you have installed MinGW toolchain into C:32 directory, then execute this:
<br />&#36; export PATH="/c/mingw32/bin:&#36;PATH&quot;<br />
- If using MSYS2 shell, execute this, if you are building for 32bit:
<br />&#36; export PATH="/c/msys2/mingw32/bin:&#36;PATH&quot;<br />
- If using MSYS2 shell, execute this, if you are building for 64bit:
<br />&#36; export PATH="/c/msys2/mingw64/bin:&#36;PATH&quot;<br />
- If using MinGW-builds toolchain (which is usually located outside of MSYS or MSYS2), then execute this in MSYS or in MSYS2:
- for MinGW (32 bit) do:
<br />&#36; ./Configure —prefix=&#36;PWD/dist no-idea no-mdc2 no-rc5 shared mingw<br />
- for MinGW-w64 do:
<br />&#36; ./Configure —prefix=&#36;PWD/dist no-idea no-mdc2 no-rc5 shared mingw64<br />
- Compile & install:
<br />&#36; make depend && make && make install<br />
Errors
- If you run into
<br />perl asm/sha1-x86_64.pl mingw64 > sha1-x86_64.s<br />gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -D_WINDLL -DOPENSSL_PIC -DOPENSSL_TH<br />READS -D_MT -DDSO_WIN32 -DL_ENDIAN -O3 -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -DOPENSSL_IA<br />32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM <s>DSHA256_ASM</s><br />DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c -o sha1-x86_<br />64.o sha1-x86_64.s<br />sha1-x86_64.s: Assembler messages:<br />sha1-x86_64.s:1824: Warning: end of file not at end of a line; newline inserted<br />sha1-x86_64.s:2183: Error: number of operands mismatch for `rol'<br />make[2]: '''* [sha1-x86_64.o] Error 1<br />make[2]: Leaving directory `/d/dev/tmp/openssl-1.0.1c/crypto/sha'<br />make[1]:'''* [subdirs] Error 1<br />make[1]: Leaving directory `/d/dev/tmp/openssl-1.0.1c/crypto'<br />make: '''* [build_crypto] Error 1<br />
check out http://openssl.6102.n7.nabble.com/Compile-error-with-MinGW-w64-td36657.html
* Use perl inside MSYS or inside MSYS2
* or change crypto/perlasm/x86_64-xlate.pl as mentioned in the e-mail thread.
Using it
- If you are using cmd.exe (Cmd-shell), then: add the bin, include, lib folders to your compilation environment:
<br />C:gt; set PATH=PATH;C:–1.0.1c\dist\bin<br />C:gt; set INCLUDE=INCLUDE;C:–1.0.1c\dist\include<br />C:gt; set LIB=LIB;C:–1.0.1c\dist\lib<br />
- If you are using MSYS2/MSYS-shell, then: add the bin, include, lib folders to your compilation environment:
<br />&#36; export PATH="&#36;PATH:/c/openssl-1.0.1c/dist/bin&quot;<br />&#36; export INCLUDE="&#36;INCLUDE:/c/openssl-1.0.1c/dist/include&quot;<br />&#36; export LIB="&#36;LIB:/c/openssl-1.0.1c/dist/lib&quot;<br />
When you now run Qt's configure.exe openssl should be detected, and Qt links against the libraries.