How to use the boost library (including shared_ptr) with the Android NDK and STLport

前端 未结 4 716
时光说笑
时光说笑 2020-12-07 14:04

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 workin

4条回答
  •  猫巷女王i
    2020-12-07 14:36

    It turned out that this approach does not entirely work when compiling a debuggable library. The release library is compiled with -O2 which optimizes out some infelicities, but the debug library is done with -O0 which reveals some additional problems. Furthermore, I wasn't too happy about having to edit the boost files. So with some additional study, I've come up with the following solution.

    First, don't edit any of the boost files. Instead add the following to the header within the std namespace:

    struct bad_cast : public exception {bad_cast operator()(){}};
    

    Next add the following to the source file:

    namespace boost
    {
        void throw_exception(std::exception const&) {}
    }
    

    This now compiles and links into the application even with android:debuggable="true" in AndroidManifest.xml. It doesn't run in the emulator, but then it wasn't doing that before I included this library either.

提交回复
热议问题