【问题标题】:Boost singleton trouble提升单身人士的麻烦
【发布时间】:2010-06-05 14:41:33
【问题描述】:

我有一些使用 boost 单例的类。它从自己的 c++ 库中调用一些函数。这个库作为依赖写在make文件中。 现在我有另一个单例类,它应该调用第一个单例类。在这段代码之后,我收到关于第一个单例中使用的函数的未定义引用的链接器错误。

当我从第二个删除调用第一个单例类时,错误删除。也许有什么问题?

class First : public boost::singleton<First>
{
   void temp() { /* Calling function from own library */ }
};

class Second : public boost:singleton<Second>
{
    const First &someInstance() const { return First::get_const_instance(); }
};

结束错误:

In function `First::temp()':
undefined reference to `Ogre::WindowEventUtilities::messagePump()'
undefined reference to `Ogre::Root::renderOneFrame()'

是的,有一个从temp调用Ogre的函数。

【问题讨论】:

  • 也许有。但除非您发布一些代码和您收到的错误消息,否则我们不太可能识别问题。

标签: c++ boost singleton


【解决方案1】:

这些错误表明你没有与 Ogre 正确链接。

如果它们在 Second 没有引用 First 时消失,那是因为 First 没有在其他任何地方被引用/使用。

您是否尝试在代码中使用First 来检查错误是否仍然存在?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 2011-03-30
    相关资源
    最近更新 更多