Installing boost 1.54.0 c++ libraries in cygwin

To install the latest boost library (1.54.0) download it from http://www.boost.org/ and unpack it. Also I installed the packages the packages zlib, zlib-devel, icu and libiconv to cygwin

cd /usr/src
wget http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.bz2
tar jxf boost_1_54_0.tar.bz2
cd boost_1_54_0
./booststrap.sh
./b2 --without-mpi install

 Troubleshooting

When running ./b2 install there is an error

./b2.exe install
Performing configuration checks

– 32-bit                   : yes
– arm                      : no
– mips1                    : no
– power                    : no
– sparc                    : no
– x86                      : yes
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
– has_icu builds           : yes
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add „using mpi ;“ to your user-config.jam
– zlib                     : yes
– iconv (libc)             : no
– iconv (separate)         : yes
– icu                      : yes
– compiler-supports-ssse3  : yes
– compiler-supports-avx2   : yes
– gcc visibility           : yes
– long double support      : no
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add „using mpi ;“ to user-config.jam.
note: to suppress this message, pass „–without-mpi“ to bjam.
note: otherwise, you can safely ignore this message.
error: No best alternative for libs/coroutine/build/allocator_sources
next alternative: required properties: <link>static <target-os>windows <threading>multi
not matched
next alternative: required properties: <link>static <segmented-stacks>on <threading>multi
not matched
next alternative: required properties: <link>static <threading>multi
not matched
– zlib                     : yes

This is a bug in `lib/coroutine/build/Jamfile.v2` which can be fixed accoring to http://superuser.com/questions/614472/error-while-installing-boost-1-54 by changing

explicit yield_sources ;

to

explicit allocator_sources ;

This seems to fix the bug, but yet still the boost.log library does not build due to other errors.

Configuring IDE

For Netbeans (7.3.1) go to „Tools -> Options“, select C/C++, choose the tab „Code Assistance -> C++ Compiler“ with the right Tool Collection (in my case Cygwin_4.x). There make sure either the path to <cygwin installation>/usr/local/include is set or add it.

Testing

Okay now a litte test if everything is working as we want it to. For that purpose we write a small program

#include <cstdlib>
#include <boost/format.hpp>

using namespace std;

int main(int argc, char** argv) {

    unsigned int arr[5] = { 0x05, 0x04, 0xAA, 0x0F, 0x0D };
    cout << boost::format("%02X-%02X-%02X-%02X-%02X")  
            % arr[0]  
            % arr[1]  
            % arr[2]  
            % arr[3]  
            % arr[4]  
         << endl;
    return 0;
}

Output should be this

05-04-AA-0F-0D

Inspired by http://fischerlaender.de/development/using-boost-c-libraries-with-gcc-g-under-windows & http://www.technical-recipes.com/2012/getting-started-with-the-boost-libraries-in-cygwin/

4 Comment

  1. gixxer_k3 says:

    Have you built Boost 1.54.0 for Raspberry Pi yet? I’m trying to cross compile it for RPi from windows 7

  2. Benjamin says:

    Sorry for getting back to you so late. Yes I have crosscompiled Boost 1.54.0 for RPi, but I used a VM running a Linux system. The problem is, that using cygwin I was not able to compile boost.log due to a bug. The bug has been reported and confirmed, but still it was faster, easier and less difficult to use a Linux VM. Just give the VM the same amount of CPUs your Host has. This will speed up compiling big time.

  3. Phillip says:

    Are you using a 32bit Cygwin?

  4. Benjamin says:

    @Phillip yes I was using the 32bit version. But eventually I gave up developing on Windows cuz it was just mere frustrating in terms of crosscompiling. Also I noticed that due to some restrains boost could not be installed completely (think it was boost-log).

    But depending on what you need from boost both cygwin x86_64 and x86 should work.

Schreibe einen Kommentar

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.