When calling boost methods causes EXC_BAD_ACCESS ( boost from Mac Port)

I ran into a weird problem.
Whatever simple boost method I call, it raised EXC_BAD_ACCESS exception. So, I tried to make a really short and simple project with which I can focus on this boost issue other than any other issues.

Why boost crashes

( Hmm.. when was my last time to use “target” instead of creating a sub project for having multiple projects under one project/workspace file? They have their own use, but for flexibility of using projects in other projects, “projects” looks better than “target”, but “target” has its own use. )

As we know, LLVM uses libc++ instead of libstdc++. So, if you create an C++/Objective-C++ project, it will use libc++ by default.

However, let’s take a look at what libraries boost libraries depend on. ( Boost is usually called header-only library. But there are ‘libraries’, really. )

JongAms-MacBookPro:lib jongp$ otool -L libboost_system-mt.dylib
libboost_system-mt.dylib:
/opt/local/lib/libboost_system-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
JongAms-MacBookPro:lib jongp$ otool -L libboost_filesystem-mt.dylib
libboost_filesystem-mt.dylib:
/opt/local/lib/libboost_filesystem-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/local/lib/libboost_system-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
JongAms-MacBookPro:lib jongp$

So, those boost libaries depends on libstdc++ not libc++.

Now, you have a clue.
If you change the C++ standard library to use from libc++ to libstdc++, it will not have the problem.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: