Back to Home

Cross-compile POCO from Windows for Linux

POCO cross compile · POCO cross compiling · Cross compiling POCO from Windows · Cross compiling POCO · POCO Linux · compile POCO for linux · analog qt · analogue qt · analogue boost · analog boost · c ++ streams · c ++ logger · tcp / ip c ++ · smart pointer c ++ · Types and Byte Order c ++ · File System c ++ · Date and Time c + · Cryptographic c ++ · Logging c ++ · Notifications c ++ · Events c ++ · cross threads c ++ · cross Libraries c ++ · URI c ++ · UUID generator c ++ · Applications c ++ · Configuration Files c ++ · Configuring Logging c ++ · Network c ++ · cross ip c ++ · cross tcp c ++ · cross udp c ++ · c ++ framework · cross framework c ++

Cross-compile POCO from Windows for Linux

  • Tutorial
POCO is a lightweight, multi-platform open-source set of C ++ libraries and classes that make writing multi-platform software easier.
Available under the Boost Software License.
For more information about POCO:
pocoproject.org/features.html
en.wikipedia.org/wiki/POCO
Well-organized class structure documentation is available in html-online, html-offline.
Documentation of the main features with examples of use - in pdf: pocoproject.org/documentation/index.html

POCO has rich functionality - very much - everything, everything you need for a happy life for a C ++ programmer! The toolkit works perfectly, has a well-thought-out API.

POCO is going for a large number of operating systems, including Desktop Windows, Windows CE, Linux.

From my own experience, I note that POCO for these operating systems is going to work without problems.
I will try to convey the methodology of cross-platform assembly from Windows for these OS, dear C ++ developers, in my three articles “Cross-compile POCO from Windows”.

Article "Cross-compile POCO from Windows for WinCE" habrahabr.ru/post/223157

Cross-compile POCO from Windows for Linux


The method was developed:
- for the Spire (ARM9) terminal cross-platform toochain
- Windows 7 64 host machine
- POCO Basic Edition 1.4.6p4

Let's assemble POCO for dynamic connection (result - files *.so) or for static connection (result - files *.a)

POCO Preparation

Prepare a directory with POCO:
- Download at pocoproject.org/download/index.html the POCO archive of the latest stable version of Basic Edition. By the button "Sources for Linux, OS X, etc.". At the time of writing, the archive - poco-1.4.6p4.tar.gz
- unzip to a separate directory. For example, using WinRAR and in the C directory: /poco/poco-1.4.6p4.

Prepare an assembly description file for Unix platforms.
This file will be used by the configure command to determine the environment (the name of the toolchain utilities and other parameters for building makefiles)
- find the "ARM-Linux" file in C: /poco/poco-1.4.6p4/build/config/ and copy it with a different name for example with the name of your platform. I named ARM-Linux-Spire.
Attention! This name will be used in the “POCO Assembly” step.
Information on the assembly description file and the assembly system: http://pocoproject.org/docs/99150-GMakeBuildNotes.html
Change our ARM-Linux - *** file in a text editor (I used Notepad ++):
1) Find and comment out lines STLPORT_INCLUDE= , STLPORT_LIB= , OPENSSL_INCLUDE= , CFLAGS= . It should turn out like this: 2) From remove It should turn out like this: 3) From remove It should turn out like this: 4) Find the line and change the toolchain utilities prefix from your equipment to. I changed it this way: Usually a cross-platform development toolchain for a Linux device comes with the hardware. This is just an archive with utilities from the GCC suite ( en.wikipedia.org/wiki/GNU_Compiler_Collection
#STLPORT_INCLUDE = /usr/local/include/stlport

#STLPORT_LIB = /usr/local/lib

#OPENSSL_INCLUDE = /usr/local/arm/2.95.3/include

#OPENSSL_LIB = /usr/local/arm/2.95.3/lib

#CFLAGS = -Isrc

SYSFLAGS =-I$(STLPORT_INCLUDE) -I$(OPENSSL_INCLUDE)

#SYSFLAGS = -I$(STLPORT_INCLUDE) -I$(OPENSSL_INCLUDE) -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT

SYSFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE -DPOCO_NO_FPENVIRONMENT

SYSLIBS =-L$(STLPORT_LIB) -L$(OPENSSL_LIB) -lstlport_arm-linux-gcc

#SYSLIBS = -L$(STLPORT_LIB) -L$(OPENSSL_LIB) -lstlport_arm-linux-gcc -lpthread -ldl -lrt

SYSLIBS = -lpthread -ldl -lrt

TOOL = arm-linuxarm-linux

TOOL = arm-unknown-linux-gnu


)

In order to find out the name of the prefix, go to the toolchain in the / bin directory, and pay attention to the file *-gcc.exeor *-g++.exe
For example, my toolchain contains the files:, so for my toolchain the prefix . 5) Find the line and assign an arbitrary name, which during assembly will be used to create directories with the results of the assembly. I assigned a name to reflect the meaningful name of the platform. Therefore, my POCO libraries will be located in after assembly . 6) Pay attention to the configuration of the build result: if you build POCO for dynamic connection: it must be in , and for static connection: it must be in
arm-unknown-linux-gnu-gcc.exe

arm-unknown-linux-gnu-g++.exe

arm-unknown-linux-gnu
POCO_TARGET_OSARCH = ARMPOCO_TARGET_OSARCH = ARM_SpireC:\poco\poco-1.4.6p4\lib\Linux\ARM_Spire


LINKMODESHARED

LINKMODESTATIC

Tool preparation

Install tools:
- MinGW msys. We will use msys shell. My MinGW came with sdk for the device, and you can get any console for Windows with copy-paste support from the official website www.mingw.org
The author used ConEmu x64 www.conemu.ru

Open a console with copy-paste support, all further steps will be from this console.

Check the availability of the toochain / bin directory, enter the name of the gcc utility from your toochain. I have this:
arm-unknown-linux-gnu-gcc -v
- if this utility is not found, then register the path to it. My path is this:
set PATH=C:\Spire\SDT\TOOLCHAIN\20140226\bin;%PATH%
- check the availability of toochain again

Check the availability of the make utility:
make -v
- if this utility is not found, then write the path to it. My path is this:
set PATH=C:\Spire\SDT\MinGW\bin;%PATH%
- check the availability of make again

Enter the msys command shell, execute:
sh
- if this utility is not found, then specify the path to it. My way is this:
set PATH=C:\Spire\SDT\MinGW\msys\1.0\bin;%PATH%

All further steps will be performed from the console with support for copy-paste + msys command shell

Install a directory with the current POCO:
cd C:/poco/poco-1.4.6p4

POCO assembly

Before assembling (for order), you can check the availability of the configurator.
./configure --help

Perform POCO configuration:
./configure --config=ARM-Linux-Spire
or, to build POCO without tests and examples:
./configure --config=ARM-Linux-Spire --no-tests --no-samples
if the configuration is successful, a message like this will be displayed:
Configured for ARM-Linux-Spire

- complete POCO assembly:
make
POCO build time with tests and examples on my PC (Intel i5 3.300Gz 8Gb) took 12 minutes.

The collected POCO libraries will be in \lib\Linuxthe directory that we defined in the variable POCO_TARGET_OSARCHin the configuration settings file.
My path to the compiled POCO libraries turned out to be this:C:\poco\poco-1.4.6p4\lib\Linux\ARM_Spire

Possible problems

I have had problems not directly related to the POCO:
-I project with static POCO not permitted according to the class AtomicCounterof the
__sync_add_and_fetch, __sync_fetch_and_add, __sync_sub_and_fetch, __sync_fetch_and_sub
solution: Add SYSFLAGS = ... -DPOCO_NO_GCC_ATOMICSto use another realization AtomicCounter.
- A project with static POCO successfully builds, but when the executable program is launched on the device, it is issued to the console:
/lib/libgcc_s.so.1: version 'GCC_4.3.0' not found (required by )this is due to unequal versions libgccon the device and toolchain on the host machine. Solution: Link the library to the executable program libgcc.

A cardinal way to find the causes of problems associated with the assembly of POCO: connect the POCO sources to the executable file and try to collect as part of the file.

Sources of information

"POCO C ++ Libraries GNU Make Build System" pocoproject.org/docs/99150-GMakeBuildNotes.html

***

Ready-made C ++ tools make our work more enjoyable and more fruitful. Good luck, dear colleagues!

Vladislav Khokhryakov.

Read Next