-fno-rttiでコンパイルされた共有ライブラリからサブクラス化しようとしています。残念ながら、私のコードベースの他のライブラリには-frttiが必要です。その結果、スーパークラスにtypeinfo構造体がないため、リンクエラーが発生します。
通常のコンパイルで受け取ったエラー:
out.o: in function typeinfo for MyClass:myclass.cpp(.data.rel.ro.<cpp magic>): error: undefined reference to 'typeinfo for NetlinkListener'
私がサブクラス化したいクラスは、libsysutilsのandroidクラスです(スペースのために少し切り取っています):
class NetlinkListener : public SocketListener {
char mBuffer[64 * 1024];
int mFormat;
public:
static const int NETLINK_FORMAT_ASCII = 0;
static const int NETLINK_FORMAT_BINARY = 1;
NetlinkListener(int socket);
NetlinkListener(int socket, int format);
virtual ~NetlinkListener() {}
protected:
virtual bool onDataAvailable(SocketClient *cli);
virtual void onEvent(NetlinkEvent *evt) = 0;
};
私のスタブは次のようになります:
class MyClass: public NetlinkListener {
public:
MyClass();
virtual ~MyClass();
int start();
int stop();
protected:
virtual void onEvent(NetlinkEvent *evt);
};
MyClassのすべてのメソッドは(空のスタブとして)実装されます
共有ライブラリ-frttiをコンパイルできません。これを回避する方法はありますか?