Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change/check the compiler used by b2 when compiling Boost?

Tags:

c++

macos

boost

Due to a problem like similar to this:

Mac OS X and static boost libs -> std::string fail

Namely I get a run-time error "pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug" when calling the boost filesystem directory iterator constructor. My impression is this can happen if boost and the program are compiled with different compilers.

So I'm trying to re-compile boost libs using the same compiler I'm using for my programs, namely macports gcc (g++-mp-4.8). Based on some online instructions, my understanding is that I edit tools/build/v2/user-config.jam, to specify the compiler, so it now says:

# Configure gcc (default version).
# using gcc ;

# Configure specific gcc version, giving alternative name to use.
# using gcc : 4.8 : g++-mp-4.8 ;

I copy user-config.jam to my home directory, rerun bootstrap.sh and rerun b2. However I still get my error that comes up ("pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug"). Is this the right procedure for specifying the compiler to use to compile? How do I check to see which compiler boost is actually using when I run b2?

like image 435
daj Avatar asked Mar 28 '13 16:03

daj


1 Answers

Leave user-config.jam in \boost\tools\build\v2. Note that lines beginning from # are comments. Your configuration should look like this (assuming that g++ is located at full/Path/ and named g++-mp4.8):

  using gcc : macports :
         full/Path/g++-mp4.8 :
  <compileflags>--sysroot=full/path/to/sysroot
  ;

You might also need to set <archiver> and <ranlib> options to allow Boost.Build locating ar and ranlib.

Invoke this configuration in b2 line like this:

b2 toolset=gcc-macports

like image 103
Igor R. Avatar answered Oct 29 '22 05:10

Igor R.