Mingw notes

From Simson Garfinkel
Revision as of 14:59, 10 September 2011 by Simson (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Cross compiling mingw.

Mingw is the GNU C Compiler set retargeted to produce Microsoft Windows executables. This makes it really easy to create C code that runs on all three platforms. mingw is pretty stable, but I want to do some fairly advanced things involving multi-threading and producing both 32-bit and 64-bit executables. That's been problematic. This page summarizes some of what I've learned.


It's not not clear what options need to be provided to both configure scripts and the compiler. There is an `-mthreads` compiler option which seems to be required for some multi-threading safety bits, whatever that means. Specifying -mthreads creates a dependcy fir mingwm10.dll, however. According to some posts I've read the dependency goes away if you are using GCC 4.5.2 or above:

You probably want to run the most recent version of the compiler, of course.

mingw on Windows

Running mingw on Windows is the most reliable method (at the moment) to compile. You can download MSys and run it. MSys is a minimal Unix environment that runs within Windows. It's "enough" to run configure scripts.

Msys shell typically runs:

   sh.exe --login -i

You can make OpenSSL with:

   $ ./config no-threads --prefix=... --openssldir='C:/mingw/msys/1.0/...'

mingw on MacOS

You can install through MacPorts, but you only get the v3 compiler:

   sudo port install i386-mingw32-binutils i386-mingw32-gcc i386-mingw32-libunicows i386-mingw32-runtime i386-mingw32-w32api

An installer for the MinGW 4.3.0 compiler (as of February 3, 2009) can be downloaded from http://crossgcc.rts-software.org/doku.php. This seems to be a powerful way to go,

mingw on Ubuntu

There are both 32-bit and 64-bit mingw compilers available for ubuntu.

  apt-get install mingw32

That gave me the 4.2.1 compiler.

I could then compile with the following maker file:

mingw on fedora

Typing yum search mingw yields a bunch of hits:

mingw32-filesystem.noarch : MinGW base filesystem and environment
mingw32-libgnurx.noarch : MinGW Regex library
mingw32-libgnurx-static.noarch : Static version of the MinGW Windows regular expression library
mingw32-runtime.noarch : MinGW Windows cross-compiler runtime
mingw32-atk.noarch : MinGW Windows Atk library
mingw32-atk-static.noarch : Static version of the MinGW Windows Atk library
mingw32-binutils.x86_64 : MinGW Windows binutils
mingw32-boost-static.noarch : Static version of the MinGW Windows Boost C++ library
mingw32-cairo.noarch : MinGW Windows Cairo library
mingw32-cairo-static.noarch : Static version of the MinGW Windows Cairo library
mingw32-cppunit.noarch : MinGW Windows C++ unit testing framework
mingw32-crossreport.noarch : Analysis tool to help cross-compilation to Windows
mingw32-curl.noarch : MinGW Windows port of curl and libcurl
mingw32-curl-static.noarch : Static version of the MinGW Windows Curl library
mingw32-dbus-static.noarch : Static version of MinGW Windows port of DBus library
mingw32-dlfcn-static.noarch : Static version of the MinGW Windows dlfcn library
mingw32-enchant.noarch : MinGW Windows Enchanting Spell Checking Library
mingw32-enchant-static.noarch : Static version of the MinGW Windows enchant library
mingw32-fontconfig.noarch : MinGW Windows Fontconfig library
mingw32-gcc.x86_64 : MinGW Windows cross-compiler (GCC) for C
mingw32-gcc-c++.x86_64 : MinGW Windows cross-compiler for C++
mingw32-gcc-gfortran.x86_64 : MinGW Windows cross-compiler for FORTRAN
mingw32-gcc-objc.x86_64 : MinGW Windows cross-compiler support for Objective C
mingw32-gcc-objc++.x86_64 : MinGW Windows cross-compiler support for Objective C++
mingw32-gdbm.noarch : MinGW port of GNU database routines
mingw32-gdk-pixbuf.noarch : MinGW Windows GDK Pixbuf library
mingw32-gettext-static.noarch : Static version of the MinGW Windows Gettext library
mingw32-glib2.noarch : MinGW Windows GLib2 library
mingw32-glib2-static.noarch : Static version of the MinGW Windows GLib2 library
mingw32-gnutls.noarch : MinGW GnuTLS TLS/SSL encryption library
mingw32-gtk2.noarch : MinGW Windows Gtk2 library
mingw32-gtk2-static.noarch : Static version of the MinGW Windows Gtk2 library
mingw32-gtkhtml3.noarch : MinGW library for embedding a lightweight web browser in GTK programs
mingw32-gtkhtml3-static.noarch : Static version of the MinGW Windows GtkHTML library
mingw32-hunspell.noarch : MinGW Windows spell checker and morphological analyzer library
mingw32-hunspell-static.noarch : Static version of the MinGW Windows hunspell library
mingw32-iconv-static.noarch : Static version of the MinGW Windows Iconv library
mingw32-jasper.noarch : MinGW Windows Jasper library
mingw32-jasper-static.noarch : Static version of the MinGW Windows Jasper library
mingw32-libffi.noarch : A portable foreign function interface library for MinGW
mingw32-libglade2.noarch : MinGW Windows Libglade2 library
mingw32-libglade2-static.noarch : Static MinGW Windows Libglade2 library
mingw32-libgpg-error.noarch : MinGW Windows GnuPGP error library
mingw32-libidn-static.noarch : Static version of the MinGW Windows IDN library
mingw32-libjpeg.noarch : MinGW Windows Libjpeg library
mingw32-libjpeg-static.noarch : Static version of the MinGW Windows Libjpeg library
mingw32-libpng.noarch : MinGW Windows Libpng library
mingw32-libsigc++20.noarch : MinGW Windows port of the typesafe signal framework for C++
mingw32-libsigsegv.noarch : MinGW library for handling page faults in user mode
mingw32-libsoup.noarch : MinGW library for HTTP and XML-RPC functionality
mingw32-libsoup-static.noarch : Static version of the MinGW Windows Libsoup library
mingw32-libssh2-static.noarch : Static version of the MinGW Windows SSH2 library
mingw32-libtiff-static.noarch : Static version of the MinGW Windows LibTIFF library
mingw32-libxml2.noarch : MinGW Windows libxml2 XML processing library
mingw32-libxml2-static.noarch : Static version of the MinGW Windows XML processing library
mingw32-libxslt-static.noarch : Static version of the MinGW Windows LibXSLT library
mingw32-openssl.noarch : MinGW port of the OpenSSL toolkit
mingw32-openssl-static.noarch : Static version of the MinGW port of the OpenSSL toolkit
mingw32-pango.noarch : MinGW Windows Pango library
mingw32-pango-static.noarch : Static version of the MinGW Windows Pango library
mingw32-pcre.noarch : MinGW Windows pcre library
mingw32-pdcurses.noarch : Curses library for MinGW
mingw32-pixman.noarch : MinGW Windows Pixman library
mingw32-pixman-static.noarch : Static version of the MinGW Windows Pixman library
mingw32-plotmm.noarch : MinGW GTKmm plot widget for scientific applications
mingw32-portablexdr.noarch : MinGW Windows PortableXDR / RPC Library
mingw32-qpid-cpp.noarch : MinGW Windows port of AMQP C++ Daemons and Libraries
mingw32-qwt.noarch : MinGW Windows Qwt library
mingw32-srvany.noarch : Utility for creating services for Windows
mingw32-termcap.noarch : MinGW terminal feature database
mingw32-w32api.noarch : Win32 header files and stubs
mingw32-webkitgtk.noarch : MinGW Windows web content engine library
mingw32-webkitgtk-static.noarch : Static version of the MinGW Windows WebKitGTK+ library
mingw32-wpcap.noarch : MinGW user-level packet capture
mingw32-zfstream.noarch : MinGW Windows abstraction API for reading and writing compressed files
mingw32-zlib.noarch : MinGW Windows zlib compression library
mingw32-zlib-static.noarch : Static libraries for mingw32-zlib development.
mingw32-OpenSceneGraph.noarch : Fedora mingw high performance real-time graphics toolkit
mingw32-SDL.noarch : MinGW Windows port of SDL cross-platform multimedia library
mingw32-SDL_image.noarch : MinGW Windows port of the Image loading library for SDL
mingw32-SDL_mixer.noarch : MinGW Windows port of Simple DirectMedia Layer's Sample Mixer Library
mingw32-atkmm.noarch : MinGW Windows C++ interface for the ATK library
mingw32-boost.noarch : MinGW Windows port of Boost C++ Libraries
mingw32-bzip2.noarch : MinGW port of bzip2 file compression utility
mingw32-cairomm.noarch : MinGW Windows C++ API for the cairo graphics library
mingw32-cpp.x86_64 : MinGW Windows cross-C Preprocessor
mingw32-dbus.noarch : MinGW Windows port of DBus
mingw32-dirac.noarch : Dirac is an open source video codec
mingw32-expat.noarch : MinGW Windows port of expat XML parser library
mingw32-freeglut.noarch : Fedora MinGW alternative to the OpenGL Utility Toolkit (GLUT)
mingw32-freetype.noarch : Free and portable font rendering engine
mingw32-gettext.noarch : GNU libraries and utilities for producing multi-lingual messages
mingw32-glibmm24.noarch : MinGW Windows C++ interface for GTK2 (a GUI library for X)
mingw32-gtk-vnc.noarch : MinGW Windows port of VNC client GTK widget
mingw32-gtkmm24.noarch : MinGW Windows C++ interface for GTK2 (a GUI library for X)
mingw32-gvnc.noarch : MinGW Windows port of VNC GObject
mingw32-iconv.noarch : GNU libraries and utilities for character set conversion
mingw32-libgcrypt.noarch : MinGW Windows gcrypt encryption library
mingw32-libglademm24.noarch : MinGW Windows C++ wrapper for libglade
mingw32-libidn.noarch : MinGW Windows Internationalized Domain Name support library
mingw32-libltdl.noarch : Runtime libraries for GNU Libtool Dynamic Module Loader
mingw32-libp11.noarch : MingGW Windows libp11 library
mingw32-libsq3.noarch : MinGW Windows C++ Wrapper for the SQLite3 embeddable SQL database engine
mingw32-libsqlite3x.noarch : MinGW Windows C++ Wrapper for the SQLite3 embeddable SQL database engine
mingw32-libssh2.noarch : MinGW Windows library implementation of the SSH2 protocol
mingw32-libtiff.noarch : MinGW Windows port of the LibTIFF library
mingw32-libxml++.noarch : MinGW Windows C++ wrapper for the libxml2 XML parser library
mingw32-libxslt.noarch : MinGW Windows Library providing the Gnome XSLT engine
mingw32-minizip.noarch : Minizip manipulates files from a .zip archive
mingw32-nsiswrapper.noarch : Helper program for making NSIS Windows installers
mingw32-openjpeg.noarch : MinGW Windows openjpeg library
mingw32-opensc.noarch : MingGW Windows OpenSC library
mingw32-pangomm.noarch : MinGW Windows C++ interface for Pango
mingw32-physfs.noarch : MinGW Windows port of the PhysicsFS library
mingw32-plib.noarch : Fedora mingw set of portable game related libraries
mingw32-plib-static.noarch : Static version of Fedora mingw set of portable game related libraries
mingw32-pthreads.noarch : MinGW pthread library
mingw32-readline.noarch : MinGW port of readline for editing typed command lines
mingw32-sigar.noarch : MinGW Windows sigar library
mingw32-sqlite.noarch : MinGW Windows port of sqlite embeddable SQL database engine
mingw32-tcl.noarch : MinGW Windows Tool Command Language, pronounced tickle
mingw32-tk.noarch : MinGW Windows graphical toolkit for the Tcl scripting language
mingw32-wpcap-docs.noarch : MinGW pcap documentation
mingw32-wpcap-examples.noarch : Example source code for MinGW pcap
mingw32-OpenThreads.noarch : OpenThreads
mingw32-celt051.noarch : An audio codec for use in low-delay speech and audio communication
mingw32-dlfcn.noarch : Implements a wrapper for dlfcn (dlopen dlclose dlsym dlerror)
mingw32-libgeotiff.noarch : GeoTIFF format library
mingw32-libogg.noarch : The Ogg bitstream file format library
mingw32-liboil.noarch : Library of Optimized Inner Loops, CPU optimized functions
mingw32-libzip.noarch : C library for reading, creating, and modifying zip archives
mingw32-nsis.x86_64 : Nullsoft Scriptable Install System
mingw32-proj.noarch : Cartographic projection software (PROJ.4)
mingw32-qt.noarch : Qt for Windows
mingw32-qt-qmake.x86_64 : Qt for Windows Build Environment
mingw32-xerces-c.noarch : MingGW Windows validating XML parser
qdevelop.x86_64 : Development environment dedicated to Qt4

I got going on Fedora Core 14 with the following commands:

  sudo yum install mingw32-pthreads

This installed the 4.5.x compiler:

[root@FC14 simsong]# i686-pc-mingw32-gcc --version
i686-pc-mingw32-gcc (GCC) 4.5.0 20100414 (Fedora MinGW 4.5.0-1.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

[root@FC14 simsong]#