0

我正在尝试从 OS X 10.6 上的 Git 源代码构建最新版本的 QMF,但我一直遇到此错误:

"QPrivatelyImplemented<QMailMessageBodyPrivate>::~QPrivatelyImplemented()", referenced from:
  QMailMessageBody::~QMailMessageBody()in qmfstoragemanager.o
  QMailMessageBody::~QMailMessageBody()in qmfstoragemanager.o
  PartStorer::operator()(QMailMessagePart const&)in qmfstoragemanager.o
  PartLoader::operator()(QMailMessagePart&)in qmfstoragemanager.o
 "QPrivatelyImplemented<QMailMessageHeaderFieldPrivate>::~QPrivatelyImplemented()", referenced from:
  QMailMessageContentType::~QMailMessageContentType()in qmfstoragemanager.o
  QMailMessageContentType::~QMailMessageContentType()in qmfstoragemanager.o
  ReferenceLoader::operator()(QMailMessagePart&)in qmfstoragemanager.o
  PartLoader::operator()(QMailMessagePart&)in qmfstoragemanager.o
"QPrivatelyImplemented<QMailMessagePartContainerPrivate>::~QPrivatelyImplemented()", referenced from:
  QMailMessage::~QMailMessage()in qmfstoragemanager.o
"QPrivatelyImplemented<QMailMessageMetaDataPrivate>::~QPrivatelyImplemented()", referenced from:
  QMailMessage::~QMailMessage()in qmfstoragemanager.o
 "QPrivatelyImplemented<QMailMessageMetaDataPrivate>::operator=(QPrivatelyImplemented<QMailMessageMetaDataPrivate> const&)", referenced from:
  QmfStorageManager::load(QString const&, QMailMessage*) in qmfstoragemanager.o
"QPrivatelyImplemented<QMailMessagePartContainerPrivate>::operator=(QPrivatelyImplemented<QMailMessagePartContainerPrivate> const&)", referenced from:
  QmfStorageManager::load(QString const&, QMailMessage*) in qmfstoragemanager.o
ld: symbol(s) not found for architecture x86_64

但是,它确实可以在 Ubuntu 下完美编译,而且我已经足够肯定我之前已经在 OS X 上编译过,所以我有点困惑,没有找到明显的符号通常意味着缺少一些源代码,任何人都遇到过这个我开始撕开它?

4

1 回答 1

1

发生此错误是因为编译器从库中省略了未引用的类。我能够通过在src\libraries\qmfclient\qmailinstantiations.cpp中的所有显式模板实例化(或只是将其添加到文件末尾)添加以下代码来解决此问题:

class reference_holder
{
    struct helper
    {
        helper(QPrivatelyImplemented<QMailMessageBodyPrivate>* = 0)
        {
        }

        ~helper()
        {
        }
    };

    static helper helper_;

    static void use_helper()
    {
        (void)helper_;
    }

    template<void(*)()>
    struct helper2 {};

    static helper2<&reference_holder::use_helper> helper2_;
};
于 2012-09-27T13:01:58.707 回答