MinGW64 how-to(内含编译openssl,libjpeg,libcurl等例子)

Index of contents


Setting up the MinGW 64 environment

MinGW 64 is an open source C/C++ compiler based on the popular gcc; basically, it is intended to generate executables for Windows 64 bit.

We‘ll suppose that you already have a basic familiarity with standard MinGW 32 + MSYSMinGW 64 is more or less the same, but acting (more or less) as a cross-compiler.
This practically means that you can build 64 bit executables on any Win32 platform: but obviously any 64 bit program requires some Windows 64 platform to be executed.

The standard build tool-chain [originally developed for Linux] natively supports cross-compilers: and this works under Windows as well, e.g. using MinGW 64.
As you surely already know, the standard build procedure is the following one:

./configure
make
make install

Using the MinGW 64 cross-compiler is the same of using standard MinGW32: but in this case you are required to always specify the following ./configure argument:

./configure --host=x86_64-w64-mingw32
make
make install

The above --host directive is enough for ./configure to intend that a cross-compilation is required: and that the intended target is Windows 64 bit.
There are many different ways to deploy MinGW 64 (this including cross-compiling on Linux or Cygwin).
After some careful preliminary testing, I choosed the following one because it appairs the most straightforward:

  • I already had MinGW32+MSYS installed on the Windows 7 64 bit box I use to develop Win32 sw:
    so I decided to install MinGW 64 as well on the same platform.
  • mixing up at random 32 bit and 64 bit binaries doesn‘t seem so good at all:
    so I‘ve purposely choosen an appropriate configuration, completely avoiding any undesirable confusion.
  • anyway, you are absolutely free to choose the configuration best fit for your specific requirements: simply read the appropriate documentation.


Once I decided the most appropriate disk layout, I duly started installing MinGW 64 on Windows 7 Pro 64 bit:

  • first I‘ve downloaded the most recent mingw-w64-bin_i686-mingw_yyyymmdd.zip for Win32
  • then I‘ve unzipped all this stuff into the C:\MinGW64 directory.
  • and finally I‘ve downloaded the most recent MinGW 64 own MSYS
  • once I‘ve installed it into the C:\msys64 directory (completing the postinstall procedure) I was immediately ready to work.

PostInstallation tasks

Step #1: carefully check the C:\msys64\etx\fstab file; it must contain the following row: (this will automatically mount C:\MinGW64 as /mingw)
C:/MinGW64 /mingw

Step #2: a dangerous issue exists: the MinGW 64 own MSYS is someway broken (as I painfully discoverd by trial and error ...): the C:\msys64\bin\find.exe executable is badly missing.
Unhappily enough, Windows has its own FIND.EXE (and it‘s a completely different thing from the Linux find): this may cause several builds to misteriously fail ... but now you are well aware of this dangerous pitfall. You simply have to manually pick find.exe from the standard MinGW 32 / MSYS installation, then copying this executable file into C:\msys64\bin.

Step #3: the cross-compiler tool-chain seems to be a little bit confused about strip real name: this simple trick seems to definitively resolve any related issue.
cp /mingw/bin/x86_64-w64-mingw32-strip.exe /mingw/bin/strip.exe

Preparing to use PKG-CONFIG:

You simply have to follow the same identical procedure already explained for standard MinGW 32 + MSYS

Learming to identify 32 bit and 64 bit exacutables

32 bit binaries file iconv.exe
PE32 executable for MS Windows (console) Intel 80386 32-bit

file libiconv-2.dll
PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit


64 bit binaries file iconv.exe
PE32+ executable for MS Windows (console) Mono/.Net assembly

file libiconv-2.dll
PE32+ executable for MS Windows (DLL) (console) Mono/.Net assembly

Setting up Windows own (SYSTEM) libraries

Some apps (and libraries) require to be actually linked against MS Windows system libraries. And this is a really puzzling task using MinGW 64.

Very shortly explained: the standard GCC tool-chain has the ability to link both .DLL dynamic libraries and .a static libraries.
When Windows own system libraries are required, this isn‘t at all an issue for MinGW 32:

  • any required system .dll is surely installed (usually on C:\Windows\System32)
  • the corresponding .a static libraries are shipped by MinGW itself (and actually simply are stubs pointing to the corresponding DLL)

But when using MinGW 64 a catastrophical issue arises:

  • on Windows 64 bit platforms C:\Windows\System32 is somehow wizardry cursed (as I discovered in the most painfull way ...)
  • when a 32 bit executable attemptes to get any DLL from C:\Windows\System32 then the 32 bit DLL will be found
  • and when a 64 bit executable attemptes to get any DLL from C:\Windows\System32 then the 64 bit DLL will be found
  • sadly, there is absolutely no way to explicity identify (by path) which one version do you really intend to access.
    a damned automamagical trick, acting as a black magic spell decides for you what are you loocking for: and there is no way to circumvent this odd behaviour.
    you can get further details from this Wikipedia article: SysWOW64
  • unhappily, the MinGW 64 tool-chain actually is a cross-compiler: it actually generates 64 bit executables, but the tool-chain tools themselves are 32 bit
  • and accordingly to this, the GCC linker will always fail when some system DLL is required, simply because it will inexorably found the corresponding 32 bit DLL instead ...
    obviously not at compatible with a 64 bit executable.

How to circumvent this dangerous pitfall

Once we have identified the reasons causing the above link failure, caring any nursing isn‘t too much difficult.

  • we simply have to copy any required Windows own system DLL on some sane and safe location, i.e. on some normalnot cursed) directory, possibly included within the linker search path.
  • all this isn‘t at all difficult: you simply have to use Windows own tools (e.g. GUI copy & paste, or the command copy from the command shell).
    Windows own tools are 64 bit executables, and will consequently magically pick up the 64 bit version of any DLL from C:\Windows\System32
  • I‘ve personally choosen C:\MinGW64\x86_x64-w64-mingw32\lib (corresponding to /mingw/x86_64-w64-mingw32-lib) as my default location.
  • The DLLs required to build SpatiaLite and friends are: gdi32.dll, msimg32, ws2_32.dll, crypt32.dll and Wldap32.dll
    Please note well: you must rename theam respectively as: libgdi32.dll, libmsimg32, libws2_32.dll, libcrypt32.dll and libwldap32.dll

All right: we are now ready to start creating our Windows 64 bit software. Let‘s go !

Be warned: building on MinGW 64 is more or less the same as building on MinGW 32: anyway here and there some further patch is absolutely required.

Please, carefully read and verbatim follow any given instruction.


Step 1) building libiconv

libiconv is the standard GNU library supporting locale charsets.
Required by: libspatialitespatialite-tools

Building under Windows is not too much difficult.

  • download libiconv-1.13.1.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd libiconv-1.13.1
./configure --host=x86_64-w64-mingw32
make
make install-strip

Anyway, this will simply build and install the DLL: a further step is required in order to get the static library as well.

make distclean
./configure --host=x86_64-w64-mingw32 --disable-shared
make
make install-strip

Now you‘ve built and installed both the static library and the DLL.
However the above process has installed badly misconfigured libcharset.la and libiconv.la files
(which are required to build other libraries in the following steps).
So in order to get a properly configured libiconv you have to accomplish a further operation:


Step 2) building libz

libz is a popular library implementing Deflate, i.e. the compression algorithm used by gzip and Zip.
Depends on: nothing
Required by: libpnglibtiff, ...

Building under Windows is quite easy, but requires to pay some attenction.

  • download the latest sources: zlib125.zip
  • uncompress this zip-file
  • then open an MSYS shell

A very simple patch is required: you must first edit the zlib-1.2.5/win32/Makefile.gcc file:

38c38
< PREFIX =
---
> PREFIX = x86_64-w64-mingw32-

After applying the above patch you are now to build zlib:

cd zlib-1.2.5
make -f win32/Makefile.gcc

Now you simply have to manually copy the following files:

cp zlib1.dll /usr/local/bin
cp zconf.h zlib.h /usr/local/include
cp libz.a /usr/local/lib
cp libzdll.a /usr/local/lib/libz.dll.a

All this will build and install both the static library and the DLL as well.
Anyway this process will not generate the libz.la file (which is required to build libtiff in one of the following steps.
So in order to get a fully installed libz you have to accomplish a further operation:

  • download libz.la
  • and then copy this file: cp libz.la /usr/local/lib

Step 3) building libjpeg

libjpeg is a popular library supporting the JPEG image compression.
Depends on: nothing
Required by: libtifflibgaiagraphics

Important notice: you can now choose between two alternative implementations:

  • libjpeg is the standard, plain library
  • libjpeg-turbo is a new library, that fully takes profit from the most recent Intel/AMD CPUs
    If you are planning to deploy your software on such platforms, then using libjpeg-turbo can ensure a 200% performance boost (and even more than this).
    I strongly recommend using libjpeg-turbo: both libraries share the same identical API/ABI (they are absolutely inter-changeable), but libjpeg-turbo runs in an impressively faster mode.

Building the one or the other under Windows is absolutely a plain and easy task.

How-to-build libjpeg-turbo

Please note: the NASM assembler is absolutely required: if you don‘t have it already installed on your system, you can download and install now.

  • download the latest sources: libjpeg-turbo-1.1.1.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd libjpeg-turbo-1.1.1
./configure --host=x86_64-w64-mingw32 --prefix=/usr/local
make
make install-strip

This will build and install both the static library and the DLL as well.

How-to-build libjpeg

  • download the latest sources: jpegsr8b.zip
  • uncompress this zip-file
  • then open an MSYS shell

cd jpeg-8b
./configure --host=x86_64-w64-mingw32 
make
make install-strip

This will build and install both the static library and the DLL as well.


Step 4) building libpng

libpng is a popular library supporting the PNG image compression.
Depends on: libz
Required by: libgaiagraphics

Building under Windows is absolutely a plain and easy task.

  • download the latest sources: libpng-1.5.2.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd libpng-1.5.2
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32
make
make install-strip

Important notice: you have to properly set the shell environment in order to retrieve the already installed libz; this is the duty of the two above export directives.
This will build and install both the static library and the DLL as well.

Important notice #2: in order to get ./configure support you must absolutely download the .tar.gz, because the .zip doesn‘t supports it.


Step 5) building libtiff

libtiff is a popular library supporting the TIFF image format.
Depends on: libzlibjpeg
Required by: libgaiagraphics

Building under Windows is absolutely a plain and easy task.

  • download the latest sources: tiff-3.9.5.zip
  • uncompress this zip-file
  • then open an MSYS shell

cd tiff-3.9.5
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32
make
make install-strip

Important notice: you have to properly set the shell environment in order to retrieve the already installed libz; this is the duty of the two above export directives.

This will build and install both the static library and the DLL as well.

Important notice: MinGW 64 seems to generate absolutely crazy .la files.
So you have to manually apply the following patch to avoid any possible further issue.
You are now required to manually edit the /usr/local/lib/libtiffxx.la file as follows:

  • search for a line starting with: dependency_libs=
  • you‘ll find within the associated value a crazy path like:
    /c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root/x86_64-w64-mingw32/lib/../lib/libstdc++.la
    -L/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/gcc/obj/x86_64-w64-mingw32/libstdc++-v3/src
    -L/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/gcc/obj/x86_64-w64-mingw32/libstdc++-v3/src/.libs
    -L/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root/x86_64-w64-mingw32/lib
    -L/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root/mingw/lib
  • simply replace all the above garbage with: C:/MinGW64/x86_64-w64-mingw32/lib/libstdc++.la
  • save and exit

Step 6) building libproj

libproj is a library supporting coordinate‘s transformation between different Reference Systems [PROJ.4]
Depends on: nothing
Required by: libgeotifflibspatialitespatialite-tools

Building under Windows is an easy task.

  • download the latest sources: proj-4.7.0.zip
  • uncompress this zip-file
  • then open an MSYS shell

cd proj-4.7.0
./configure --host=x86_64-w64-mingw32 --without-mutex
make
make install-strip

Important notice: may well be you‘ll get the following fatal errors:

pj_mutex.c:167: error: redefinition of ‘pj_acquire_lock‘
pj_mutex.c:65: error: previous definition of ‘pj_acquire_lock‘ was here
pj_mutex.c:181: error: redefinition of ‘pj_release_lock‘
pj_mutex.c:75: error: previous definition of ‘pj_release_lock‘ was here
pj_mutex.c:192: error: redefinition of ‘pj_cleanup_lock‘
pj_mutex.c:82: error: previous definition of ‘pj_cleanup_lock‘ was here
pj_mutex.c:206: error: redefinition of ‘pj_init_lock‘
pj_mutex.c:91: error: previous definition of ‘pj_init_lock‘ was here

in such an evenience you have to edit the -/src/pj_mutex.c source as follows:

33c33
< #ifndef _WIN32
---
> #if defined (_WIN32) && !defined(__MINGW32__)

40c40
< #ifndef _WIN32
---
> #if defined (_WIN32) && !defined(__MINGW32__)

Step 7) building libgeotiff

libgeotiff is a library supporting the GeoTIFF raster format
Depends on: libtifflibproj
Required by: libgaiagraphics

Building under Windows is an easy task.

  • download the latest sources: libgeotiff130.zip
  • uncompress this zip-file
  • then open an MSYS shell

cd libgeotiff-1.3.0
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --enable-incode-epsg
make
make install-strip

Important notice: it doesn‘t seem possible to build as a DLL using MinGW + MSYS. AFAIK, there is no way to do such a thing.
So you have to manually apply the following patch to circumvent this issue. Edit the /usr/local/lib/libgeotiff.la file as follows:

10c10
< library_names=‘‘
---
> library_names=‘libgeotiff.a‘


Step 8) building libgeos

libgeos is a library representing a C++ porting of JTS [Java Topology Suite].
Depends on: nothing
Required by: libspatialitespatialite-tools

This library really is an huge and complex piece of software; building on Windows is an incredibly time consuming task.

  • download the latest sources: geos-3.3.0.tar.bz2
  • uncompress this bzip2-file
  • then untar the tarball
  • and finally open an MSYS shell

cd geos-3.3.0
./configure --host=x86_64-w64-mingw32

Important notice: before attempting to start compiling you are required to manually apply the following patch:
(not at all elegant, but fully effective); so edit the geos-3.3.0/include/geos/platform.h header:

near line 62:
------------
< #ifdef HAVE_INT64_T_64
<   typedef int64_t int64;
< #else
< # ifdef HAVE_LONG_LONG_INT_64
<    typedef long long int int64;
< #  else
<    typedef long int int64;
< #  ifndef HAVE_LONG_INT_64
< #   define INT64_IS_REALLY32 1
< #   warning "Could not find 64bit integer definition!"
< #  endif
< # endif
< #endif
---
> /*
> #ifdef HAVE_INT64_T_64
>   typedef int64_t int64;
> #else
> # ifdef HAVE_LONG_LONG_INT_64
>    typedef long long int int64;
> #  else
>    typedef long int int64;
> #  ifndef HAVE_LONG_INT_64
> #   define INT64_IS_REALLY32 1
> #   warning "Could not find 64bit integer definition!"
> #  endif
> # endif
> #endif
> */
> typedef long long int int64;

and now you are relly ready to start building GEOS:

make
make install-strip

This will build and install both the static library and the DLL as well.

Important notice: we have already seen this about libtiffMinGW 64 seems to generate absolutely crazy .la files.
So you have to manually apply the following patch to avoid any possible further issue.
You are now required to manually edit both /usr/local/lib/libgeos.la and /usr/local/lib/libgeos_c.la files as follows:

  • search for a line starting with: dependency_libs=
  • simply replace any crazy path with: C:/MinGW64/x86_64-w64-mingw32/lib/libstdc++.la
  • save and exit

Step 9) building libexpat

libexpat is a well known standard library supporting XML parsing.
Depends on: nothing
Required by: libfontconfigspatialite-tools, ...

Building under Windows really is a piece-of-cake.

  • download the latest sources: expat-2.0.1.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd expat-2.0.1
./configure --host=x86_64-w64-mingw32

Important notice: before attempting to start compiling you are required to manually apply the following patch:
(not at all elegant, but fully effective); so edit the C:\MinGW64\x86_64-w64-mingw32\include\process.h header:

165c165:
------------
< int __cdecl execv(const char *_Filename,char *const _ArgList[]) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
---
> int __cdecl execv(const char *_Filename,const char * _ArgList[]) __MINGW_ATTRIB_DEPRECATED_MSVC2005;

and now you are really ready to start building expat (you can recover back again the above change once you‘ve terminated):

make
make install

This will build and install both the static library and the DLL as well.


Step 10) building libspatialite

libspatialite is the main core of SpatiaLite
Depends on: libiconvlibprojlibgeos
Required by: spatialite-toolslibrasterlite

Building under Windows is an easy task.

cd libspatialite-amalgamation-3.0.0-beta
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --target=mingw32
make
make install-strip

This will build and install both the static library and the DLL as well.

Important notice: we have already seen this about libtiffMinGW 64 seems to generate absolutely crazy .la files.
So you have to manually apply the following patch to avoid any possible further issue.
You are now required to manually edit both /usr/local/lib/libspatialite.la files as follows:

  • search for a line starting with: dependency_libs=
  • simply replace any crazy path with: C:/MinGW64/x86_64-w64-mingw32/lib/libstdc++.la
  • save and exit

Step 11) building spatialite-tools

spatialite-tools the SpatiaLite command-line management tools
Depends on: libiconvlibprojlibgeoslibspatialitelibexpat
Building under Windows is an easy task.

First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

After this you are now ready to build as usual:

cd spatialite-tools-3.0.0-beta
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --target=mingw32
make
make install-strip

Please note: following the above method you‘ll get dynamically linked tools [i.e. depending on DLLs].
If you whish instead to build statically linked tools [i.e. self contained, not depending on DLLs], you must first
manually edit the Makefile-static-MinGW file as follows:

< CC = g++
---
> CC = x86_64-w64-mingw32-g++‘

after this you are now ready to build your statically linked tools:

mkdir static_bin
make -f Makefile-static-MinGW
cp static_bin/* /usr/local/bin


Step 12) building wxWidgets MSW

wxWidgets is a popular widgets library, supporting GUI in a cross-platform fashion; MSW is the specific porting supporting Windows.
Depends on: nothing
Required by: spatialite-guispatialite-gis

This library really is an huge and complex piece of software; building on Windows is an incredibly time consuming task, but is quite plain and easy.

  • download the latest sources: wxMSW-2.8.12.zip
  • uncompress this zip-file
  • then open an MSYS shell

export "CXXFLAGS=-fpermissive"     [this directive is absolutely required to skip some blocking errors]
cd wxMSW-2.8.12
mkdir msw_build
cd msw_build
../configure --host=x86_64-w64-mingw32 --disable-shared --disable-debug \
    --disable-threads --enable-monolithic --enable-unicode \
    --without-libjpeg --without-libpng --without-zlib\
    --without-libtiff --without-expat --without-regex

Please note: the wxMSW ./configure is highly configurable: you must apply exactly the above settings.
Anyway, when ./configure stops, it‘s a good practice to check if the final report looks exactly like this:

Configured wxWidgets 2.8.12 for `x86_64-w64-mingw32‘

Which GUI toolkit should wxWidgets use?                 msw
  Should wxWidgets be compiled into single library?       yes
  Should wxWidgets be compiled in debug mode?             no
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets be compiled in Unicode mode?           yes
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.4      no
                                       wxWidgets 2.6      yes
  Which libraries should wxWidgets use?
                                       jpeg               no
                                       png                no
                                       regex              no
                                       tiff               no
                                       zlib               no
                                       odbc               no
                                       expat              no
                                       libmspack          no
                                       sdl                no

now, when ./configure stops, you have to continue as usual:

make
make install-strip

Important notice: wxWidgets is now configured for any further usage: but unhappily it assumes being on Win32, and this is obviously wrong.
So you must manually adjust the wx-config script (/usr/local/bin/wx-widgets) as follows:

  • search for a line starting with: ldlibs_base=
  • and on the corresponding value then simply delete: -lwctl3d32
    (this obsolete library doesn‘t exists any longer on Win64, and isn‘t actually required at all).
  • now search for any occurrenct of the string: --define __WIN32__ --define __WIN95__ --define __GNUWIN32__
  • and replace the above value with: --define WX_CPU_AMD64
    (this is required so to create 64 bit resource files)
  • save and exit

Step 13) building libfreetype

libfreetype is a standard library supporting TrueType fonts.
Depends on: nothing
Required by: libcairo, ...

Building under Windows is an easy task.

  • download the latest sources: freetype-2.4.4.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd freetype-2.4.4
./configure --host=x86_64-w64-mingw32
make
make install

This will build and install both the static library and the DLL as well.


Step 14) building libfontconfig

libfontconfig is a standard library supporting font customization and configuration.
Depends on: libexpatlibfreetypelibiconv
Required by: libcairo, ...

Building under Windows is an easy task.

  • download the latest sources: fontconfig-2.8.0.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd fontconfig-2.8.0
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --disable-docs
make
make install-strip

This will build and install both the static library and the DLL as well.


Step 15) building libpixman

libpixman is the standard library implementing pixel manipulation for Cairo.
Depends on: nothing
Required by: libcairo, ...

Building under Windows is an easy task.
First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

All right, your system configuration is ready to build fontconfig, so you can now:

  • download the latest sources: pixman-0.20.2.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd pixman-0.20.2
./configure --host=x86_64-w64-mingw32
make
make install-strip

This will build and install both the static library and the DLL as well.


Step 16) building libcairo

libcairo is a very popular graphics library.
Depends on: libpixmanlibfreetypelibfontconfiglibpng
Required by: libgaiagraphics, ...

Building under Windows is a little bit harder than usual.
First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

All right, your system configuration is ready to build libcairo, so you can now:

  • download the latest sources: cairo-1.10.2.tar.gz
  • uncompress this gzipped-file
  • then untar the tarball
  • and finally open an MSYS shell

cd cairo-1.10.2
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --disable-pthread
make
make install-strip

Important notice: you‘ll probably get a fatal error at some time during the compilation:
to resolve this issue you should manually edit the cairo-1.10.2/src/cairo.c source:

near line 149:
------------
< };
< #include <assert.h>

< /**
<  * _cairo_error:
---
> };
> #include <assert.h>

> #ifdef __MINGW32__
> #define ffs __builtin_ffs
> #endif

> /**
>  * _cairo_error:

This will build and install both the static library and the DLL as well.


Step 17) building libgaiagraphics

libgaiagraphics is a common utility library supporting graphics rendendering
Depends on: libjpeglibpnglibtifflibgeotifflibcairo

Required by: spatialite-gui [next-to-come releases of librasterlite and spatialite-gis]

Building under Windows is an easy task.
First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

All right, your system configuration is ready to build libgaiagraphics, so you can now:

cd libgaiagraphics-0.4
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32 --target=mingw32
make
make install-strip

This will build and install both the static library and the DLL as well.


Step 18) building spatialite_gui

spatialite_gui the SpatiaLite GUI user-friendly tool
Depends on: libspatialitewxWidgetslibgaiagraphics
Building under Windows is an easy task.

First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

After this you are now ready to build as usual:

cd spatialite_gui-1.5.0-beta
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32
make
make install-strip

Please note: following the above method you‘ll get a dynamically linked GUI tool [i.e. depending on DLLs].
If you whish instead to build a statically linked GUI tool [i.e. self contained, not depending on DLLs], now type:

mkdir static_bin
make -f Makefile-static-MinGW
cp static_bin/* /usr/local/bin


Step 19) building OpenSSL

OpenSSL is a well known standard library supporting SSL, i.e. the encrypted HTTPS web protocol.
Depends on: nothing
Required by: libcurl

Building under Windows is a little bit difficult, and requires to pay close attention.
The configure script isn‘t at all a standard one: please read carefully the following instructions.

  • download the latest sources: openssl-1.0.0d.tar.gz
  • Important notice: you cannot use tools such as 7z to untar the tarball: this will cause fatal errors during compilation (broken links).
    You absolutely have to run all the following commands from the MSYS shell.

tar zxvf openssl-1.0.0d.tar.gz
cd openssl-1.0.0d
./Configure mingw64 --prefix=/usr/local shared no-asm

Several manual adjustments are now required; you must first edit openssl-1.0.0d/Makefile:

62c62
< CC= gcc
---
> CC= x86_64-w64-mingw32-gcc

62,63c62,63
< AR= ar $(ARFLAGS) r
< RANLIB= /c/MinGW/bin/ranlib.exe
< NM= nm
---
> AR= x86_64-w64-mingw32-ar $(ARFLAGS) r
> RANLIB= x86_64-w64-mingw32-ranlib.exe
> x86_64-w64-mingw32-nm

75c75
< MAKEDEPPROG= gcc
---
> MAKEDEPPROG= x86_64-w64-mingw32-gcc

After applying the above patches you are now to build OpenSSL:

export "CROSS_COMPILE=x86_64-w64-mingw32-
make
make install

This will build and install both the static libraries and the DLLs as well.


Step 20) building libcurl

libcurl is a well known library supporting URLs (networking, web protocols)
Depends on: libzOpenSSL
Required by: ?

Building under Windows is an easy task.

  • download the latest sources: curl-7.21.7.zip
  • uncompress this zip-file
  • then open an MSYS shell

First of all, you must check if you‘ve already installed pkg-config.exe
If not, please read the above instructions

And now you must set the PKG_CONFIG_PATH as appropriate:

export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"

After this you are now ready to build as usual:

cd curl-7.21.7
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --host=x86_64-w64-mingw32
make
make install-strip

Important notice: you‘ll probably get a fatal error at some time during the compilation:
to resolve this issue you should manually edit the curl-7.21.7/src/main.c source:

near line 465:
------------
< static int ftruncate64(int fd, curl_off_t where)
< {
<   if(_lseeki64(fd, where, SEEK_SET) < 0)
<     return -1;

<   if(!SetEndOfFile((HANDLE)_get_osfhandle(fd)))
<     return -1;

<   return 0;
< }
< #define ftruncate(fd,where) ftruncate64(fd,where)
---
> /*
> static int ftruncate64(int fd, curl_off_t where)
> {
>   if(_lseeki64(fd, where, SEEK_SET) < 0)
>     return -1;

>   if(!SetEndOfFile((HANDLE)_get_osfhandle(fd)))
>     return -1;

>   return 0;
> }
> #define ftruncate(fd,where) ftruncate64(fd,where)
> */

This will build and install both the static library and the DLL as well.



back

https://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#open-ssl

时间: 2024-10-12 12:52:09

MinGW64 how-to(内含编译openssl,libjpeg,libcurl等例子)的相关文章

Ubuntu+NDK编译openssl(为了Android上使用libcurl且支持HTTPS协议)

为了Android上使用libcurl且支持HTTPS协议,需要依赖openssl,因此先来了解一下如何编译OpenSSL1.编译ARM下的共享库(默认的)我使用的是guardianproject的openssl,它已经提供好了android的ndk makefile.git clone https://github.com/guardianproject/openssl-android.git然后直接cd到该目录,$NDK/ndk-build就行.注意默认的使用NDKr5b,如果没有该版本,请

Ubuntu+NDK编译openssl

为了Android上使用libcurl且支持HTTPS协议,需要依赖openssl,因此先来了解一下如何编译OpenSSL1.编译ARM下的共享库(默认的)我使用的是guardianproject的openssl,它已经提供好了android的ndk makefile.git clone https://github.com/guardianproject/openssl-android.git然后直接cd到该目录,$NDK/ndk-build就行.注意默认的使用NDKr5b,如果没有该版本,请

静态编译OpenSSL并整合到Qt

静态编译OpenSSL并整合到Qt 来源 https://blog.csdn.net/lixiaoxin1989/article/details/78421573 MSVC版本: 1. 下载OpenSSL源码 1.1 下载OpenSSL的源码:https://www.openssl.org/source/ 1.2 解压到C:\openssl-1.0.2l 2. 编译OpenSSL源码 2.1 打开VS的命令工具: 32位: 64位: 2.2 使用cd命令定位到源码文件夹: cd C:\opens

基于源码编译openssl

openssh依赖于openssl,由于ssl频繁曝出漏洞,牵扯到openssh.而自身也存在漏洞... 00.下载openssl https://www.openssl.org/source/ https://github.com/openssl/openssl/releases https://www.openssl.org/source/openssl-1.0.2l.tar.gz 01.准备工作 yum -y install perl perl-devel gcc gcc-c++ 02.编

在Windows下编译OpenSSL(VS2005和VC6)

需要说明的是请一定安装openssl-0.9.8a .  openssl-1.0.0我没有编译成功. 如何在Windows下编译OpenSSL (Vs2005使用Vc8的cl编译器)1.安装ActivePerl//初始化的时候,需要用到perl解释器2.使用VS2005下的Visual Studio 2005 Command Prompt进入控制台模式(这个模式会自动设置各种环境变量)3.解压缩openssl的包,进入openssl的目录4.perl configure VC-WIN32尽量在这

如何在 Windows 下编译 OpenSSL VS2013

OpenSSL是一个开源的第三方库,它实现了SSL(Secure SocketLayer)和TLS(Transport Layer Security)协议,被广泛企业应用所采用.对于一般的开发人员而言,在http://slproweb.com/products/Win32OpenSSL.html 上下载已经编译好的OpenSSL库是省力省事的好办法.对于高级的开发用户,他们可能需要适当的修改或者裁剪OpenSSL,那么编译它就成为了一个关键问题.本篇博客就是主要讲述如何早Windows上编译Op

mac编译openssl扩展报错 openssl.c:44:10: fatal error: &#39;openssl/evp.h&#39; file not found

解决办法 brew link openssl --force 然后 ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config make sudo make install mac编译openssl扩展报错 openssl.c:44:10: fatal error: 'openssl/evp.h' file not found

Windows环境下使用VS2005编译OpenSSL

如何Windows环境下,使用VS2005编译OpenSSL,虽然这个问题在Baidu.Google上一堆,但安装中还是遇到些问题,在这里 记录下来希望能帮助大家不要在走弯路.注:我是在WinXP SP3下使用VS2005SP1下编译成功的,OpenSSL的版本是0.9.8l. http://www.cnblogs.com/moonset7/archive/2009/12/18/1627317.html by 月落上弦 一.编译OpenSSL  准备工作:下载OpenSSL源码 官方网站下载Op

win7在64位系统下编译openssl

以前在笔记本上配置过openssl-0.9.8g版本,今天在公司的台式机上配置死活没配置成功,机器的系统是win7,64位,编译openssl-1.0.1e出现各种莫名的错误,最后无意中编译了1.0.0.a版本编译成功了. 如果出现ml找不到的时候,直接在vc10.0/bin下拷贝就好. 参考文章:http://blog.chinaunix.net/uid-20479991-id-216269.html win7在64位系统下编译openssl,布布扣,bubuko.com