Compile Poco with MinGW on Windows

caboose0013 picture caboose0013 · Feb 1, 2013 · Viewed 7.4k times · Source

I need to compile poco with MinGW so I can use it in Qt Creator but cannot figure out how to, I've managed to compile poco in Visual Studio but I cannot use those libraries in Qt Creator.

Answer

Cesar Ortiz picture Cesar Ortiz · Feb 1, 2013

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!