【问题标题】:Undefined reference to typeinfo when linking with nsRunnable与 nsRunnable 链接时对 typeinfo 的未定义引用
【发布时间】:2012-05-09 08:00:33
【问题描述】:

由于 firefox 12 sdk 删除了“代理”对象,我想通过 nsRunnable 使用 cross-thread calls。我基本上做了代码的复制和粘贴:

class NotifyTask : public nsRunnable
{
public:
  NotifyTask(nsISupports *subject, const char *topic, bool remref)
    : mWorkerThread(do_GetCurrentThread())
  {
    MOZ_ASSERT(!NS_IsMainThread()); // This should be running on the worker thread
  }

  NS_IMETHOD Run() {
    MOZ_ASSERT(NS_IsMainThread()); // This method is supposed to run on the main thread!

    mWorkerThread->Shutdown();
    return NS_OK;
  }

private:
  nsCOMPtr<nsIThread> mWorkerThread;
};

我试图编译它。我收到以下错误:

g++ -std=gnu++0x -Wall -O2 -c  -DUSE_LIBUSB -fPIC -DHAVE_CRYPTO -fpermissive -DCRYPTPP -fshort-wchar -I../../xulrunner-sdk/include -o gipsy.o gipsy.cpp
gipsy.cpp:74:7: warning: ‘NotifyTask’ declared with greater visibility than the type of its field ‘NotifyTask::<anonymous>’ [-Wattributes]
gipsy.cpp:74:7: warning: ‘NotifyTask’ declared with greater visibility than its base ‘nsRunnable’ [-Wattributes]
g++ -std=gnu++0x -Wl,-z,defs -Wall -Os -o gipsy.so -shared gipsy.o gipsymodule.o tracklog.o gpslib/data.o gpslib/garmin.o gpslib/gps.o gpslib/phys.o gpslib/igc.o gpslib/aircotec.o cp1250.o prefparser.o gpslib/foreignigc.o gpslib/mlr.o gpslib/flymaster.o gpslib/compeo.o gpslib/iq.o ../libs/libcryptopp.a -lusb -L../../xulrunner-sdk/lib -lxpcomglue_s -lxul -lxpcom -lplds4 -lplc4 -lnspr4 -lpthread -ldl -lmozalloc
gipsy.o:(.data.rel.ro._ZTI10NotifyTask[typeinfo for NotifyTask]+0x10): undefined reference to `typeinfo for nsRunnable'
collect2: ld returned 1 exit status

根据g++ undefined reference to typeinfo,gecko sdk 可能是使用 -fvisibility=hidden 和一些奇怪的“不同 .so 中的关键方法”构建的。这是 Gecko sdk 中的错误还是我做错了什么?

【问题讨论】:

    标签: c++ gecko


    【解决方案1】:

    gecko SDK 未与 RTTI 链接 - 将“-fno-rtti”参数添加到特定的 .o 文件解决了该问题。

    【讨论】:

      猜你喜欢
      • 2010-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-11
      • 2021-02-16
      • 2011-08-07
      • 2015-09-09
      • 2019-02-12
      相关资源
      最近更新 更多