Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use the boost library (including shared_ptr) with the Android NDK and STLport
    text
    copied!<p>This is more of an answer than a question, because I've figured it out, at least as far as cleanly compiling the library. The main issue for me was to get shared_ptr working.</p> <p><strong>Ingredients:</strong></p> <p>Boost v. 1.45.0</p> <p>The version of STLport at <a href="http://www.anddev.org/viewtopic.php?p=29939">http://www.anddev.org/viewtopic.php?p=29939</a>.</p> <p>Version r4b of the NDK.</p> <p><strong>Directions:</strong></p> <p>In your Android.mk file add:</p> <pre><code>LOCAL_CFLAGS += -DBOOST_EXCEPTION_DISABLE -D_STLP_NO_EXCEPTIONS -DOS_ANDROID -D_STLP_USE_SIMPLE_NODE_ALLOC </code></pre> <p>Remove the call to __stl_throw_length_error at line 613 of stlport/stl/_string.h. You can use _STLP_NO_EXCEPTIONS if you like.</p> <p>Edit boost/boost/smart_ptr/shared_ptr.hpp after line 261 to get rid of the call to boost::throw_exception in the shared_ptr constructor. I used #ifndef BOOST_EXCEPTION_DISABLE around the entire body of the method. (But see the answer below.)</p> <p>Next you need to supply some missing pieces. Create a header file with the following:</p> <pre><code>#ifdef OS_ANDROID #include &lt;exception&gt; namespace std { struct bad_alloc : public exception { bad_alloc operator()(){}}; } #endif </code></pre> <p>and a source file with a stripped-down exception class to support bad_alloc:</p> <pre><code>#ifdef OS_ANDROID #include &lt;exception&gt; namespace std { exception::exception() {} exception::~exception() {} const char* exception::what() const {} } #endif </code></pre> <p>Include the header wherever you're including boost/shared_ptr.hpp. Compile the source and add it to your library.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload