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

Posted by Ionic on Stack Overflow See other posts from Stack Overflow or by Ionic
Published on 2011-01-15T03:45:24Z Indexed on 2011/01/15 3:53 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

Hi all,

I'm experiencing some very weird problems with static boost libraries under Mac OS X 10.6.6.

The error message is

main(78485) malloc: *** error for object 0x1000e0b20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1]    78485 abort (core dumped)

and a tiny bit of example code which will trigger this problem:

#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem.hpp>
#include <iostream>

int main (int argc, char **argv) {
  std::cout << boost::filesystem::current_path ().string () << '\n';
}

This problem always occurs when linking the static boost libraries into the binary. Linking dynamically will work fine, though.

I've seen various reports for quite a similar OS X bug with GCC 4.2 and the _GLIBCXX_DEBUG macro set, but this one seems even more generic, as I'm neither using XCode, nor setting the macro (even undefining it does not help. I tried it just to make sure it's really not related to this problem.)

Does anybody have any pointers to why this is happening or even maybe a solution (rather than using the dynamic library workaround)?

Best regards,

Mihai

© Stack Overflow or respective owner

Related posts about c++

Related posts about osx