Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable Exceptions and RTTI in Boost libraries?

I develop some native libraries for Android and use Boost libraries - just headers-based ones. The problem I am facing is that when I try to link some of my native libraries against some system library the UnsatisfiedLinkError is thrown. It is due to different C++ runtimes as stated in the NDK documentation:

You can only select a single C++ runtime that all your code will depend on. It is not possible to mix shared libraries compiled against different C++ runtimes.

System libraries do not use RTTI and Exceptions, but my libraries use it implicitly. I know there are macros BOOST_EXCEPTION_DISABLE and BOOST_NO_RTTI, but I am not able to make it working. I tried to set them as compiler flags and in the config.hpp as well, but with no luck – still getting many errors like

cannot use typeid with -fno-rtti

How can I disable these features in Boost, is it even possible?

like image 762
vitakot Avatar asked Jun 30 '12 20:06

vitakot


1 Answers

The answer is "maybe". Some boost libraries will work with exceptions disabled - some will not. Same for RTTI.

I suggest you check the documentation for the particular boost libraries that you are interested in.

For example, Boost.Array will work with exceptions disabled, but Boost.Format will not.

If you are getting messages like cannot use typeid with -fno-rtti, that will probably be while compiling some part of Boost that requires RTTI. Where the error occurs will tell you which library (usually).

like image 76
Marshall Clow Avatar answered Oct 23 '22 21:10

Marshall Clow