Showing posts with label boost. Show all posts
Showing posts with label boost. Show all posts

Monday, October 12, 2015

Boost and ICU build scripts for MinGW-w64

My MinGW distro is long gone now. However I still privately use a MinGW-w64 toolchain to test and study C++.

I have kept two scripts to build both ICU and Boost so I can have Boost libraries always available.

The scripts are for the latest version of both libraries. Build first ICU, uncompress the generated package and then build Boost.

You will need:

Steps:

  • Create a directory, eg, C:\mingw-build;
  • Under this directory create other three directories: dest, scripts and sources;
  • Copy both icu-55.1-w64-amd64.sh and boost-1.59.0-w64-amd64.sh to the scripts directory;
  • Download icu4c-55_1-src.tgz and icu4c-55_1-data.zip from ICU site to the sources directory;
  • Download boost_1_59_0.tar.bz2 from Boost site to the sources directory;
  • Download the MinGW-w64 toolschain and uncompress it to C:\MinGW64
  • Configure your system and add C:\MinGW64\bin to the PATH
  • Download the tools (bsdtar, diff, patch, gnufind, bzip2 and xz) to C:\MinGW64\bin (or any other directory in the PATH);
  • Open Bash;
  • Go to the scripts directory: cd /c/mingw-build/scripts
  • Execute the ICU build script: ./icu-55.1-w64-amd64.sh
  • If the build is successful the icuc-55.1-w64-amd64.tar.xz file is created in the C:\mingw-build\dest directory;
  • Go to the MinGW64\bin directory: cd /c/MinGW64
  • Uncompress the ICU package: bsdtar xzf /c/mingw-build/dest/icuc-55.1-w64-amd64.tar.xz
  • Go back to the scripts directory: cd /c/mingw-build/scripts
  • Execute the Boost build script: ./boost-1.59.0-w64-amd64.sh
  • If the build is successful the boost-1.59.0-w64-amd64.tar.xz file is created in the C:\mingw-build\dest directory;
  • Go to the MinGW64\bin directory: cd /c/MinGW64
  • Uncompress the Boost package: bsdtar xzf /c/mingw-build/dest/boost-1.59.0-w64-amd64.tar.xz
  • Now you have a MinGW-w64 installation with the Boost libraries

Please send your feedback: comments, suggestions and bug reports!!

DISCLAIMER: the scripts are provided "as is" without warranty of any kind.

Friday, February 08, 2013

Boost C++ Libraries release 1.53.0

The new release (1.53.0) of Boost Libraries was made available on February 4th, just 3 days after I released the Feburary 2013 edition of my MinGW distro that included release 1.52.0. Because of this I have built the new release and I'm making it available here as a separated download. As usual it also includes the ICU versions of both Boost RegEx and Boost Locale libraries. The next release of the MinGW distro will contain this version of Boost (or a newer if released meanwhile).
Assuming you have installed it in C:\MinGW directory:
  • Clean up the existing Boost files:
cd C:\MinGW
rmdir /s /q include\boost
del lib\libboost*.*
cd C:\MinGW
bin\bsdtar -xvJf boost-1.53.0.tar.xz

Monday, August 13, 2012

Exceptions and Destructors: The Saga Continues

Still on the subject of exceptions and destructors, I wondered what is the behavior when using threads. Note that exceptions do not propagate across threads, so catching exceptions in your main thread is not enough. You also have to catch in each and every thread.
Let's take the sample from the original article and introduce threads with a little help of Boost:

#include <iostream>
#include <stdexcept>
#include <boost/thread.hpp>

struct A {
  A () { std::cout << "A\n"; }
  ~A () { std::cout << "~A\n"; }
};

void myfunc() {
  A temp;
  throw std::runtime_error("moo");
}

void mythread() {
  myfunc();
}

int main() {
  try {
    boost::thread t(mythread);
    t.join();
  }
  catch (...) {
  }
}

This still will not call the destructor unless you catch in the thread:

void mythread() {
  try {
    myfunc();
  }
  catch (...) {
  }
}

So, it is a good practice to have a catch clause for all your threads.

With Visual C++ 11 and Gnu C++ 4.7.1 (with --std=c++11 option) std::thread class you don't need the catch clause to get the destructor called. I couldn't find if this is standard or a side effect of the implementation of std::thread on C++ standard libraries for those compilers.