Compile Poco with MinGW on Windows
Asked Answered
R

5

7

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.

Rubellite answered 1/2, 2013 at 0:36 Comment(1)
Note that you can also use msvc in qt creator (with a Qt for MSVC). I'd go that route.Sarsen
A
3

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.

Alyshaalysia answered 9/2, 2013 at 20:12 Comment(0)
D
9

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!

Debarath answered 1/2, 2013 at 13:25 Comment(2)
Thank you. I compiled it, but how do I use .a libraries in Qt Creator?Rubellite
I don't know how to do it with Qt creator because I usually work with Eclipse, but I guess you should configure your linker libraries (-lPocoFoundation, -lPocoNet, etc) and make the #includes of your Poco libs from your code. Make sure your project knows where are your .h headers and your .a libraries and make a tryDebarath
S
3

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.

Spradling answered 4/2, 2013 at 4:50 Comment(0)
A
3

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.

Alyshaalysia answered 9/2, 2013 at 20:12 Comment(0)
S
3

There is an MSYS2 package providing everything needed for installation of the current (at the time of writing) POCO C++ Library 1.9.0.

  • To install this package, you first need to download and install MSYS2 from msys2.org
  • Using pacman (they integrated a port of the Arch Linux package manager), you can identify the POCO C++ package you want to install: pacman -Ss poco gets you a list of packages where poco is part of the name. This may look like the following:
$ pacman -Ss poco
mingw32/mingw-w64-i686-poco 1.9.0-1
    POrtable COmponents C++ Libraries (mingw-w64)
mingw64/mingw-w64-x86_64-poco 1.9.0-1
    POrtable COmponents C++ Libraries (mingw-w64)
  • I wanted to install the 64 bit package named mingw64/mingw-w64-x86_64-poco and therefore used pacman to install it:
$ pacman -S mingw64/mingw-w64-x86_64-poco
  • This installs, however the pre-built, dynamic version of POCO C++. On my system, the libraries landed in the install directory of msys2

    • C:\msys64\mingw64\bin (DLLs came here)
    • C:\msys64\mingw64\lib (.a came here)
Subsidiary answered 6/5, 2019 at 12:23 Comment(0)
P
0

There maybe a error as follow:

strip: '/Learn/POCO/poco-1.4.6p2/lib/MinGW/ia32/libPocoFoundation.dll.exe': No such file

we can resolve the problem by change line in file "build\rules\global"

STRIPCMD = $(STRIP) $@$(BINEXT) 

to

STRIPCMD = $(STRIP) $@$
Pfeiffer answered 16/11, 2013 at 3:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.