zoukankan      html  css  js  c++  java
  • MinGW 如何编译 libiconv,libz,libjpeg…

    原文地址:http://www.gaia-gis.it/spatialite-2.4.0-3/mingw_how_to.html 

    Index of contents


    the MinGW + MSYS environment

    MinGW is an open source C/C++ compiler based on the popular gcc; MSYS is a command shell supporting a minimalistic Linux-like environment on Windows.
    Using both them you can build standard open source software [originally developed for Linux] under Windows as well, simply using the classic build tool-chain, as in:

    ./configure
    make
    make install

    Quite obviously, Windows isn't exactly the same as Linux, so you cannot expect to get always an easy and painless build.
    May well be you have to adapt something here and there in order to get a successful build under Windows.
    The following notes are aimed exactly to this goal: allow you to avoid wasting your time while fighting against oddities that can quite easily solved.

    We'll suppose you are using the current MinGW 5.1.4 and MSYS 1.0.10
    So, if you have installed anything using the default settings [the wisest thing to do], now you have the following path correspondence:

    C:\msys\1.0\local will be mapped [in the MSYS own perspective] as: /usr/local

    Accordingly, this one will be the standard home for any software you'll then build and install.

    Step 1) installing libiconv

    libiconv is the standard GNU library supporting locale charsets.
    Required by: libspatialite, spatialite-tools

    Building under Windows is really difficult, so the easiest way is the one to install the precompiled binaries.
    • download libiconv-win-x86-1.9.2.zip
    • uncompress this zip-file
    • then manually copy any file respectively on:
      • C:\msys\1.0\local\bin
      • C:\msys\1.0\local\include
      • C:\msys\1.0\local\lib

    Step 2) building libz

    libz is a popular library implementing Deflate, i.e. the compression algorithm used by gzip and Zip.
    Required by: libpng, libtiff, librasterlite

    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
    cd zlib125
    cp win32/Makefile.gcc .
    make -f Makefile.gcc
    export "INCLUDE_PATH=/usr/local/include"
    export "LIBRARY_PATH=/usr/local/lib"
    make install -f makefile.gcc
    cp zlib1.dll /usr/local/bin
    cp libzdll.a /usr/local/lib

    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.
    Required by: libtiff, librasterlite

    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. cd libjpeg-turbo-1.0.0
    ./configure --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: jpegsr8a.zip
    • uncompress this zip-file
    • then open an MSYS shell
    cd jpeg-8a
    ./configure
    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: librasterlite

    Building under Windows is absolutely a plain and easy task.
    • download the latest sources: lpng143.zip
    • uncompress this zip-file
    • then open an MSYS shell
    cd lpng143
    cp scripts/makefile.mingw .

    now you have to manually edit the makefile.mingw file completing some variable defs as follows:
    • DESTDIR=/usr/local
    • ZLIBLIB=/usr/local/lib
    • ZLIBINC=/usr/local/include
    make -f makefile.mingw
    cp png.h pngconf.h /usr/local/include
    cp libpng.a libpng.dll.a /usr/local/lib
    cp libpng14.dll pngtest-stat.exe pngtest.exe /usr/local/bin

    Important notice: the latest libpng-1.4.3 doesn't supports ./configure
    So you have to apply the above instructions in order to build this library.

    Step 5) building libtiff

    libtiff is a popular library supporting the TIFF image format.
    Depends on: libz, libjpeg
    Required by: librasterlite

    Building under Windows is absolutely a plain and easy task.
    • download the latest sources: tiff-3.9.4.zip
    • uncompress this zip-file
    • then open an MSYS shell
    cd tiff-3.9.4
    export "CFLAGS=-I/usr/local/include"
    export "LDFLAGS=-L/usr/local/lib"
    ./configure
    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.

    Step 6) building libproj

    libproj is a library supporting coordinate's transformation between different Reference Systems [PROJ.4]
    Required by: libgeotiff, libspatialite, spatialite-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 --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: libz, libjpeg, libtiff, libproj
    Required by: librasterlite

    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 --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].
    Required by: libspatialite, spatialite-tools

    This library really is an huge and complex piece of software; building on Windows is an incredibly time consuming task, and may be quite complex.
    • download the latest sources: geos-3.2.2.tar.bz2
    • uncompress this zip-file
    • then open an MSYS shell
    cd geos-3.2.2
    ./configure
    make
    make install-strip

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

    Important notice: using standard MinGW you'll get the following fatal errors:

    C:/MinGW/bin/../gcc/mingw32/3.4.5/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/3.4.5/cwchar:161:
    error: '::swprintf' has not been declared

    C:/MinGW/bin/../gcc/mingw32/3.4.5/http://www.cnblogs.com/http://www.cnblogs.com/include/c++/3.4.5/cwchar:168:
    error: '::vswprintf' has not been declared


    This is because GEOS sets the -ansi switch, and MinGW support for strict ANSI mode is somehow broken.
    Fixing this issue requires some little hacking:
    • go to the C:\MinGW\include\c++\3.4.5 dir
    • edit the cwchar file [as shown in the following table], save end exit
    • after applying this patch, GEOS will build without any further problem.
    line 160    using ::putwchar;
    line 161    // using ::swprintf;
    line 162    using ::swscanf;
    line 163    using ::ungetwc;
    line 164    using ::vfwprintf;
    line 165#if _GLIBCXX_HAVE_VFWSCANF
    line 166    using ::vfwscanf;
    line 167#endif
    line 168    // using ::vswprintf;
    line 169#if _GLIBCXX_HAVE_VSWSCANF
    line 170    using ::vswscanf;
    line 171#endif
    line 172    using ::vwprintf;

    Step 9) building expat

    expat is a well known standard library supporting XML parsing.
    Depends on: nothing
    Required by: spatialite-tools

    Building under Windows really is a piece-of-cake.
    • download the latest sources: expat-2.0.1.tar.gz
    • uncompress this tar.gz file
    • then open an MSYS shell
    cd expat-2.0.1
    ./configure
    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: libiconv, libproj, libgeos
    Required by: spatialite-tools, librasterlite

    Building under Windows is an easy task. cd libspatialite-amalgamation-2.4.0
    export "CFLAGS=-I/usr/local/include"
    export "LDFLAGS=-L/usr/local/lib"
    ./configure --target=mingw32
    make
    make install-strip

    Step 11) building spatialite-tools

    spatialite-tools the SpatiaLite command-line management tools
    Depends on: libiconv, libproj, libgeos, libspatialite, expat
    Building under Windows is an easy task. cd spatialite-tools-2.4.0
    export "CFLAGS=-I/usr/local/include"
    export "LDFLAGS=-L/usr/local/lib"
    ./configure --target=mingw32
    make
    make install-strip

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

    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], now type:

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

    Step 12) building libgaiagraphics

    libgaiagraphics is a common utility library supporting graphics rendendering
    Depends on: libjpeg, libpng, libtiff, libgeotiff, libz

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

    Building under Windows is an easy task. cd libgaiagraphics-0.1
    export "CFLAGS=-I/usr/local/include"
    export "LDFLAGS=-L/usr/local/lib"
    ./configure
    make
    make install-strip

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

    Step 13) building wxWidgets MSW

    wxWidgets is a popular widgets library, supporting GUI in a cross-platform fashion; MSW is the specific porting supporting Windows.
    Required by: spatialite-gui, spatialite-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.11.zip
    • uncompress this zip-file
    • then open an MSYS shell
    cd wxMSW-2.8.11
    mkdir msw_build
    cd msw_build
    ../configure --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.11 for `i686-pc-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               builtin
                                           png                builtin
                                           regex              builtin
                                           tiff               builtin
                                           zlib               builtin
                                           odbc               no
                                           expat              builtin
                                           libmspack          no
                                           sdl                no

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

    make
    make install-strip


    Step 14) building libharu

    libharu is an interesting and innovative library supporting generation of PDF documents.
    Depends on: libz, libpng
    Required by: spatialite-gis

    Building under Windows is an easy task. cd libharu-2.1.0
    export "CFLAGS=-I/usr/local/include"
    export "LDFLAGS=-L/usr/local/lib"
    ./configure
    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.
  • 相关阅读:
    windows10 中 svn 代码统计工具 StatSVN 使用详解
    Windows 10 安装 JDK14 Java 环境,没有 jre 包
    GET和POST两种基本请求方法的区别
    图解HTTP学习笔记(一)WEB基础
    【LinuxShell】cp 用法详解
    博客陆续迁移中...
    显示git忽略文件
    字符串遍历
    SDWebImage源码分析(二)
    其他
  • 原文地址:https://www.cnblogs.com/loongfee/p/2268991.html
Copyright © 2011-2022 走看看