Compile Poco with MinGW on Windows

With this enviroment:

  • MinGW (GCC 4.7.0) + MSYS
  • Poco 1.4.6 (downloaded at 5 febrery 2013)

This is how I configure and compile Poco for MinGW and Windows 7:

  1. Extract Poco into a folder of your choice. C:/ for this example.
  2. Apply the next path to avoid copysign error.(From https://github.com/pocoproject/poco/issues/57).

    In the file C:\poco-1.4.6\Foundation\include\Poco\FPEnvironment_DUMMY.h

    Delete the string std:: in this method:

    inline float FPEnvironmentImpl::copySignImpl(float target, float source)
    {
    #if defined(__APPLE__) || defined(POCO_ANDROID)
        return copysignf(target, source);
    #else
        return /*std::*/copysignf(target, source);
    #endif
    }
    

    And here too:

    inline double FPEnvironmentImpl::copySignImpl(double target, double source)
    {
    #if defined(__APPLE__) || defined(POCO_ANDROID)
        return copysign(target, source);
    #else
        return /*std::*/copysign(target, source);
    #endif
    }
    
  3. Modify MinGW configuration at C:\poco-1.4.6\build\config\MinGW. (From http://cidebycide.blogspot.com.es/2012/06/building-poco-c-witn-mingw.html)

    You should delete the -mno-cygwin string in line:

    SHLIB   = $(CXX) -shared -mno-cygwin -o $@ -Wl,--out-implib=$(dir $@)$(subst cyg,lib,$(basename $(notdir $@))).a
    

    and

    SYSFLAGS = -mno-cygwin -D_WIN32 -DMINGW32 -DWINVER=0x500 -DPOCO_NO_FPENVIRONMENT -DPCRE_STATIC -DPOCO_THREAD_STACK_SIZE -DFoundation_Config_INCLUDED -I/usr/local/include -I/usr/include
    

    If you don't need to use cryptography and SSL, you should remove the options -lssl, and -lcrypto at SYSLIBS line.

  4. Compile Poco without demos, SSL, cryptography and ODBC support:

    $ ./configure --omit=NetSSL_OpenSSL,Crypto,Data/ODBC,Data/MySQL --prefix=./_INSTALL
    $ make clean
    $ make -j4 -nodemos
    $ make install
    

Good luck!


Building POCO with MinGW should not be a big deal, it's been done in the past but core developers have no incentive (not our "itch") and none of the folks complaining steps up to own and maintain MinGW build; we'd more than welcome someone taking that role. Anyone interested can contact me.


Complementing Cesar's answer (here, instead of adding a comment, for formatting purposes), you need something like this on your .pro file:

INCLUDEPATH += "<path_to_poco_include_dir>"
LIBS += -L"<path_to_poco_lib_dir>" -l<poco_lib> -l<poco_lib>

E.g., in my case, I would have this (for debug builds):

INCLUDEPATH += "C:/Dev/lib/poco/poco143/Debug/include"
LIBS += -L"C:/Dev/lib/poco/poco143/lib" -lPocoFoundationd -lPocoUtild

You can then refine this a bit, by creating settings for both debug and release builds:

LIB_HOME = "C:/Dev/lib/"
POCO_HOME = $${LIB_HOME}poco/poco143/

# SEE http://www.qtcentre.org/threads/23655-Does-Qt-Creator-understand-debug-release-scopes-in-pro-files
# OR http://www.qtcentre.org/threads/30430-How-to-set-pro-file-about-debug-and-release
####
CONFIG(debug, debug|release) {
CONFIG -= debug release
CONFIG += debug
}

CONFIG(release, debug|release) {
CONFIG -= debug release
CONFIG += release
}
####

debug {
POCO_DEBUG = d
POCO_PATH = $${POCO_HOME}Debug
}

release {
POCO_DEBUG =
POCO_PATH = $${POCO_HOME}Release
}

INCLUDEPATH += "$${POCO_PATH}/include"
LIBS += -L"$${POCO_PATH}/lib" -lPocoFoundation$${POCO_DEBUG} -lPocoUtil$${POCO_DEBUG}

Hope this helps.