未定义的引用`vtable for ... with RTTI support

时间:2012-10-10 07:24:45

标签: android android-ndk botan

我创建了一个使用RTTI支持dynamic_cast的应用程序。我在Application.mk文件中添加了“APP_CPPFLAGS + = -frtti”,但我收到错误:“未定义引用`vtable for ...”。如果我不使用RTTI,我会收到错误:“错误:'dynamic_cast'不允许使用 - fno-rtti”

我得到了输出:

    ./obj/local/armeabi-v7a/objs/vnptsofthsm/VNPTCASoftHSM/botan_impl/global_rng.o: In function `~RandomNumberGenerator':
    D:\Duongpd\Token\TMS\vnpt.example.TestSoftHSM/jni/VNPTCASoftHSM/botan_impl/../botan/../botan/rng.h:90: undefined reference to `vtable for Botan::RandomNumberGenerator'
    D:\Duongpd\Token\TMS\vnpt.example.TestSoftHSM/jni/VNPTCASoftHSM/botan_impl/../botan/../botan/rng.h:90: undefined reference to `vtable for Botan::RandomNumberGenerator'
    D:\Duongpd\Token\TMS\vnpt.example.TestSoftHSM/jni/VNPTCASoftHSM/botan_impl/../botan/../botan/rng.h:90: undefined reference to `vtable for Botan::RandomNumberGenerator'
    D:\Duongpd\Token\TMS\vnpt.example.TestSoftHSM/jni/VNPTCASoftHSM/botan_impl/../botan/../botan/rng.h:90: undefined reference to `vtable for Botan::RandomNumberGenerator'
   ./obj/local/armeabi-v7a/objs/vnptsofthsm/VNPTCASoftHSM/botan_impl/global_rng.o:(.data.rel.ro+0x8): undefined reference to `typeinfo for Botan::RandomNumberGenerator'

这是Botan :: RandomNumberGenerator:

class RandomNumberGenerator
   {
   public:

      static RandomNumberGenerator* make_rng();

      virtual void randomize(byte output[], size_t length) = 0;

      SecureVector<byte> random_vec(size_t bytes)
         {
         SecureVector<byte> output(bytes);
         randomize(&output[0], output.size());
         return output;
         }

      byte next_byte();

      virtual bool is_seeded() const { return true; }

      virtual void clear() = 0;

      virtual std::string name() const = 0;

      virtual void reseed(size_t bits_to_collect) = 0;

      virtual void add_entropy_source(EntropySource* source) = 0;

      virtual void add_entropy(const byte in[], size_t length) = 0;

      RandomNumberGenerator() {}
      virtual ~RandomNumberGenerator() {}
   private:
      RandomNumberGenerator(const RandomNumberGenerator&) {}
      RandomNumberGenerator& operator=(const RandomNumberGenerator&)
         { return (*this); }
   };

我的Application.mk:

APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -DANDROID
APP_ABI := armeabi-v7a

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

Here人们成功为Android构建了 botan 库。请注意,他们使用较旧的NDK,并且根本没有rtti选项。最有可能的是,你也不需要它。