5

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?

Community
  • 1
  • 1
daj
  • 6,962
  • 9
  • 45
  • 79

1 Answers1

7

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

Igor R.
  • 14,716
  • 2
  • 49
  • 83
  • 1
    What's the relationship between specifying the compiler in user-config.jam and specifying it to ./configure ( http://www.boost.org/doc/libs/1_53_0/libs/config/doc/html/index.html )? I found this a bit confusing. Is this just two ways to specify the same thing or is configure completely unrelated? – daj Mar 29 '13 at 11:45
  • One other thing that I found strange was that when I uncommented what I wrote above and used toolset=gcc, I wound up with lots of linker errors complaining about undefined command line arguments to ld. I tried changing it to "darwin : 4.8 : gcc-mp-4.8" and used toolset=darwin and somehow that got rid of the linker errors (although there were a lot of warnings about "typedef '[XXX]' locally defined but not used"). – daj Mar 29 '13 at 11:49
  • 1
    @daj 1) `Boost.Config` documentation says: "This configure script only sets up the Boost headers for use with a particular compiler. It has no effect on Boost.Build, or how the libraries are built". 2) When you invoke `toolset=gcc`, it goes to the default gcc configuration; what you actually mean is `toolset=gcc-4.8` - this would invoke the section that starts with `using gcc : 4.8 : g++-mp-4.8 ;` – Igor R. Mar 29 '13 at 20:36
  • 1
    @daj see the following link for details: http://www.boost.org/boost-build2/doc/html/bbv2/overview/configuration.html – Igor R. Mar 29 '13 at 20:36
  • `tools\build\v2` folder does not exist – user7860670 Jul 03 '23 at 07:34