How to upgrade your MinGW with commonly used libraries

This is a cheatsheet for installing libraries in MinGW, be sure to setup a development environment according to this tutorial first: How to install MinGW, MSYS and Eclipse on windows

Libraries

Zlib

  • download zlib-1.2.5.tar.gz
    tar -zxvf zlib-1.2.5.tar.gz
    cd zlib-1.2.5
    ./configure –prefix=/mingw
    make
    make install
    gcc -shared -o /mingw/bin/zlib1.dll -Wl,–out-implib=/mingw/lib/libz.dll.a \[!em\]\*.o
    

Freetype

  • download freetype-2.3.12.tar.gz
    tar -zxvf freetype-2.3.12.tar.gz
    cd freetype-2.3.12
    ./configure –prefix=/mingw
    make
    make install
    

Curl

  • download curl-7.20.0.tar.gz
    tar -zxvf curl-7.20.0.tar.gz
    cd curl-7.20.0
    ./configure –prefix=/mingw
    make
    make install
    

Freeglut

  • download freeglut-2.6.0.tar.gz
    tar -zxvf freeglut-2.6.0.tar.gz
    cd freeglut-2.6.0
    ./configure –prefix=/mingw
    make
    make install
    

Glew

  • download glew-1.5.2.zip
    unzip glew-1.5.2.zip
    cd glew-1.5.2
    make
    make install GLEW\_DEST=/mingw
    

SDL

  • download SDL-1.2.14.tar.gz
    tar -zxvf SDL-1.2.14.tar.gz
    cd SDL-1.2.14
    ./configure –prefix=/mingw
    make
    make install
    

Iconv

  • download libiconv-1.13.1.tar.gz
    tar -zxvf libiconv-1.13.1.tar.gz
    cd libiconv-1.13.1
    ./configure –prefix=/mingw –enable-static=yes
    make
    make install
    

Giflib

  • download giflib-4.1.6.tar.gz
    tar -zxvf giflib-4.1.6.tar.gz
    cd giflib-4.1.6
    ./configure –prefix=/mingw
    make
    make install
    

Jpeg

  • download jpegsrc.v8a.tar.gz
    tar -zxvf jpegsrc.v8a.tar.gz
    cd jpeg-8a
    ./configure –prefix=/mingw
    make
    make install
    

Png

  • download libpng-1.4.1.tar.gz
    tar -zxvf libpng-1.4.1.tar.gz
    cd libpng-1.4.1
    ./configure –prefix=/mingw
    make
    make install
    

Tiff

Be sure to apply the patch for building libtiff

  • download tiff-3.9.2.tar.gz
    tar -zxvf tiff-3.9.2.tar.gz
    cd tiff-3.9.2
    ./configure –prefix=/mingw
    make
    make install
    

Libxml2 (Precompiled)

In the shell:

cd /mingw/bin
pexports libxml2.dll > libxml2.def
dlltool –dllname libxml2.dll –def libxml2.def –output-lib ../lib/libxml2.a

Instructions taken from this site and this site

Boost

tar -zxvf boost_1_42_0.tar.gz
copy boost dir (with header files) to /mingw/include

20 responses

  1. ./con… doesn’t work on windows ri8? or is there a way to make it work

    nikhilsimha – April 6th, 2010
  2. You need to use msys to compile the libraries. It provides a linux like console and supports ./configure

    Laurence Muller April 21st, 2010
  3. Hi Laurence, These instructions are a great help. It has been a long time since I’ve done C++ programming, and what I have done wasn’t advanced. So on to my question… I’m trying to install zlib. I attempted ./configure…, and I’m getting this message: $ ./configure -prefix=/mingw Checking for gcc… Please use win32/Makefile.gcc instead. Then I tried: $ make Please use ./configure first. Thank you. Any ideas? Also, zlib-1.2.3 is not available, but 1.2.5 is. I installed 1.2.5. Is that ok? Finally, any tips on good books to understand C++ and all this dependency stuff?

    Frank Henard – May 12th, 2010
  4. Any ideas on the “Please use win32/Makefile.gcc instead” message?

    Frank Henard – May 13th, 2010
  5. I found this in http://www.gaia-gis.it/spatialite-2.4.0/mingw_how_to.html: cd zlib123 cp win32/makefile.gcc makefile.gcc That may be what I need.

    Frank Henard – May 13th, 2010
  6. cp win32/makefile.gcc makefile.gcc doesn’t work at all and I cant find anything that works on the net.

    jV – May 31st, 2010
  7. I was able to compile zlib. Here’s what I did: tar –lzma -xvf ./msys-build-zlib zlib-1.2.5.tar.bz2 patch < ./configure -prefix=/mingw make make install gcc -shared -o /mingw/bin/zlib1.dll -Wl,–out-implib=/mingw/lib/libz.dll.a [!em]*.o make check

    Greg Tada – July 13th, 2010
  8. Now I can’t seem to get libtiff to build. Getting a recursive error during link stage (object name conflicts in archive).

    Greg Tada – July 13th, 2010
  9. As a variant on what worked for Greg with zlib, what I did was “make -f win32/makefile.gcc”, and then just copied the *.a files into /mingw/lib and the *.exe into /mingw/bin. At that point the example.exe seemed to work.

    Daryl Lee – September 20th, 2010
  10. if you are running windows vista or later, try to run the console (cmd) as administrator and run the normal postinstallation script manually within this console with administrator rights… this solved the problem for me. i didnt get the error message anymore. if you want to get zlib-1.2.3: http://prdownloads.sourceforge.net/libpng/zlib-1.2.3.tar.gz?download

    chris – October 29th, 2010
  11. The zlib link seems to be dead. Since the rest of the libraries work great, I think it would be great if you found a live link for the newer version. The dead link can be discouraging to n00bs like me.

    Brian – April 29th, 2011
  12. @Brian: Thanks for letting me know, I’ve update and changed the URL to the SF mirror. As always you can also visit http://www.zlib.net/ for the most up to date version of zlib.

    Laurence Muller May 3rd, 2011
  13. Instead of copying, you should run “make install -f win32/Makefile.gcc”. So, it conforms standard procedure of building from sources under GNU/Linux: “make && make install” chain. Good luck.

    Dmitry F. Volosnykh – July 16th, 2011
  14. Sorry, before running “make install …”, you should define variables BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH to appropriate mingw folders. Well, read the win32/Makefile.gcc itself ;)

    Dmitry F. Volosnykh – July 16th, 2011
  15. a) zlib http://www.zlib.net/ cd into the folder If you try to run ./configure from mingw you will probably get “Please use win32/Makefile.gcc instead.” Do “make -f win32/Makefile.gcc” You will need to add some lines to your path before you can install zlib. Try either of these options. Either way you will run the same make command: ‘make install -f win32/Makefile.gcc’ option 1: prepend the path variable before you call make: >‘BINARY_PATH=/mingw/bin INCLUDE_PATH=/mingw/include LIBRARY_PATH=/mingw/lib make install -f win32/Makefile.gcc’ option 2: add the path definitions inside your win32/Makefile.gcc file: BINARY_PATH=/mingw/bin INCLUDE_PATH=/mingw/include LIBRARY_PATH=/mingw/lib , then install zlib with ‘make install -f win32/Makefile.gcc’

    Thedemon007 December 4th, 2011
  16. This doesn’t work at all. ./configure is not a command I can run from a cmd.exe prompt. Where do I extract these files to, and how do I install them in windows. I need every single step, you’re leaving out something major that I’m just not getting. Charles.

    Charles – April 25th, 2012
  17. You’re not suppose to use cmd.exe to compile these libraries, you need to install MinGW/MSYS and use the MinGW shell with these commands.

    Laurence Muller April 25th, 2012
  18. Sorry to revive this thread. I met with problems while compiling freetype in mingw I’ve gotten beyond ./configure –prefix=/mingw. I’m at the make step. seems like the make script is trying to create a folder /.lib which is illegal in windows. I have no idea how to get pass this problem. I was hoping there was a more elegant way of installing libraries than copying files by hand.

    Teong Leong April 10th, 2013
  19. Are you saying it’s trying to create a .lib directory at the root of the drive? (for instance C:.lib or D:.lib etc. That’s what I gather from the /.lib) The .libs directories get created just fine normally. The libtool script in the toplevel source dir handles creating those dirs (objdir=.libs). Note, should be .libs, not .lib. Maybe there’s a typo in the script or something.

    Marc Williams – May 29th, 2013
  20. Nice post man, thanks for it. BRAZIL

    Ciro Meneses May 10th, 2016