Compiling OpenSSL with MinGW: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
==Compiling OpenSSL with MinGW==
==Compiling OpenSSL with MinGW or MinGW-w64==


Qt 5 / QtWebkit can make use of OpenSSL, which MinGW distributions do not ship.
Qt 5 / QtWebkit can make use of OpenSSL, which MinGW distributions do not ship.
Line 6: Line 6:


The [http://slproweb.com/products/Win32OpenSSL.html Win32OpenSSL project] ''[slproweb.com]'' provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2008 runtime being installed.
The [http://slproweb.com/products/Win32OpenSSL.html Win32OpenSSL project] ''[slproweb.com]'' 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==
==Compiling on your own==
Line 11: Line 13:
===Requirements===
===Requirements===


* <span class="caps">MSYS</span> command prompt (an sh shell + some <span class="caps">UNIX</span> 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.)
* Either use <span class="caps">MSYS</span>, or use [[MSYS2]] :
* Perl
** <span class="caps">MSYS</span> shell command prompt (an sh shell + some <span class="caps">UNIX</span> 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.
* Working MinGW, or MinGW-w64 toolchain
** [[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 &amp; load MinGW, or, get &amp; load MinGW-w64 toolchains (from their respective project website), or, use “MinGW-w64” toolchains from MSYS2 repo, inside the MSYS2-shell.
** <span class="caps">NOTE</span>: 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 &amp; all sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components &amp; main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from “MinGW-builds”, then for all sub-components &amp; main project, use same MinGW-builds toolchains.


===How to build===
===How to build===


* Download latest OpenSSL from http://www.openssl.org/source (e.g. openssl-1.0.1c.tar.gz)
* Download latest+stable [https://www.openssl.org/ OpenSSL] ''[openssl.org]'' (You must use <span class="caps">HTTPS</span> secure encrypted connection to obtain source file) from https://www.openssl.org/source (e.g. openssl-1.0.1c.tar.gz)
* Start a <span class="caps">MSYS</span> command prompt (C:\msys\1.0\msys.bat)
* Either start <span class="caps">MSYS</span>-shell, or start MSYS2-shell:
* Extract tar.gz using <span class="caps">MSYS</span> tar (and ignore the symlink warnings)
** Start a <span class="caps">MSYS</span> shell command prompt (C:\msys\1.0\msys.bat)
** Or, start MSYS2 shell command prompt (C:\msys2\msys2_shell.bat)
*** See inside this [[MSYS2]] page, how to prepare MSYS2 with build/compile related toolchains, tools &amp; dependencies
 
* Extract source tar.gz using <span class="caps">MSYS</span> 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.''
** ''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.''


Check that gcc is in <span class="caps">PATH</span>, otherwise add it, e.g.<br />
* Unzip/decompress source:<br />
 
* Check that gcc is in <span class="caps">PATH</span>, otherwise add it: change below command to match with your-side directory’s exact name &amp; letter-case &amp; location:
** If using MinGW-builds toolchain (which is usually located outside of <span class="caps">MSYS</span> or MSYS2), then execute this in <span class="caps">MSYS</span> or in MSYS2:<br />
** If using <span class="caps">MSYS</span> shell, and if you have installed MinGW toolchain into C:\mingw32 directory, then execute this:<br />
** If using MSYS2 shell, execute this, if you are building for 32bit:<br />
** If using MSYS2 shell, execute this, if you are building for 64bit:<br />


for MinGW (32 bit) do:<br />
* for MinGW (32 bit) do:<br />


for MinGW-w64 do:<br />
* for MinGW-w64 do:<br />


Compile &amp; install:<br />
* Compile &amp; install:<br />


==Errors==
==Errors==


If you run into
* If you run into<br />
 
check out http://openssl.6102.n7.nabble.com/Compile-error-with-MinGW-w64-td36657.html


* Use <span class="caps">MSYS</span> perl
* check out http://openssl.6102.n7.nabble.com/Compile-error-with-MinGW-w64-td36657.html
* or change crypto/perlasm/x86_64-xlate.pl as mentioned in the e-mail thread.
** Use perl inside <span class="caps">MSYS</span> or inside MSYS2
** or change crypto/perlasm/x86_64-xlate.pl as mentioned in the e-mail thread.


==Using it==
==Using it==


Add the bin, include, lib folders to your compilation environment, e.g. for cmd.exe:
* Add the bin, include, lib folders to your compilation environment, e.g. for cmd.exe (Cmd-shell) :<br />
* Add the bin, include, lib folders to your compilation environment, e.g. for MSYS2/MSYS-shell :<br />


When you now run Qt’s configure.exe openssl should be detected, and Qt links against the libraries.
When you now run Qt’s configure.exe openssl should be detected, and Qt links against the libraries.

Revision as of 07:14, 10 February 2015

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 [slproweb.com] 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 :
  • 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 [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:\msys\1.0\msys.bat)
    • Or, start MSYS2 shell command prompt (C:\msys2\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:
  • 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:
    • If using MSYS shell, and if you have installed MinGW toolchain into C:\mingw32 directory, then execute this:
    • If using MSYS2 shell, execute this, if you are building for 32bit:
    • If using MSYS2 shell, execute this, if you are building for 64bit:
  • for MinGW (32 bit) do:
  • for MinGW-w64 do:
  • Compile & install:

Errors

  • If you run into

Using it

  • Add the bin, include, lib folders to your compilation environment, e.g. for cmd.exe (Cmd-shell) :
  • Add the bin, include, lib folders to your compilation environment, e.g. for MSYS2/MSYS-shell :

When you now run Qt’s configure.exe openssl should be detected, and Qt links against the libraries.

Categories: