外部DLL中缺少QT信号
Qt signals missing in external dll
我在应用程序中使用的iris XMPP库中有信号。在Mac OS X和Linux上一切正常,但是Windows会产生一堆未找到警告的信号。
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::AdvancedConnector
warning: QObject::connect: signal not found in XMPP::QCATLSHandler
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::ClientStream
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
warning: QObject::connect: signal not found in XMPP::Client
我试图使用的一个信号的示例是
signals:
void srvLookup(const QString &server);
我的连接电话
conn = std::make_shared<XMPP::AdvancedConnector>();
QObject::connect(conn.get(), &XMPP::AdvancedConnector::srvLookup, this, &XmppConnection::connServerLookupHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::srvResult, this, &XmppConnection::connServerResultHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::httpSyncStarted, this, &XmppConnection::connHttpSyncStartedHandler);
QObject::connect(conn.get(), &XMPP::AdvancedConnector::httpSyncFinished, this, &XmppConnection::connHttpSyncFinishedHandler);
if(QCA::isSupported("tls")) {
tls = make_unique<QCA::TLS>();
tlsHandler = make_unique<XMPP::QCATLSHandler>(tls.get());
// dont check the certificate because we self sign
tlsHandler->setXMPPCertCheck(false);
QObject::connect(tlsHandler.get(), &XMPP::QCATLSHandler::tlsHandshaken, this, &XmppConnection::tlsHandshakenHandler);
} else {
tls = 0;
tlsHandler = 0;
}
stream = std::make_shared<XMPP::ClientStream>(conn.get(), tlsHandler.get());
QObject::connect(stream.get(), &XMPP::ClientStream::connected, this, &XmppConnection::streamConnectedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::securityLayerActivated, this, &XmppConnection::streamSecurityLayerActivatedHanlder);
QObject::connect(stream.get(), &XMPP::ClientStream::needAuthParams, this, &XmppConnection::streamNeedAuthParamsHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::authenticated, this, &XmppConnection::streamAuthenticatedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::connectionClosed, this, &XmppConnection::streamConnectionClosedHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::delayedCloseFinished, this, &XmppConnection::streamDelayedCloseFinished);
QObject::connect(stream.get(), &XMPP::ClientStream::readyRead, this, &XmppConnection::streamReadyRead);
QObject::connect(stream.get(), &XMPP::ClientStream::stanzaWritten, this, &XmppConnection::streamStanzaWritten);
QObject::connect(stream.get(), &XMPP::ClientStream::warning, this, &XmppConnection::streamWarningHandler);
QObject::connect(stream.get(), &XMPP::ClientStream::error, this, &XmppConnection::streamErrorHandler);
xmpp = std::make_shared<XMPP::Client>();
QObject::connect(xmpp.get(), &XMPP::Client::rosterRequestFinished, this, &XmppConnection::onRosterRequestFinished);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemAdded, this, &XmppConnection::onRosterItemAdded);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemUpdated, this, &XmppConnection::onRosterItemUpdated);
QObject::connect(xmpp.get(), &XMPP::Client::rosterItemRemoved, this, &XmppConnection::onRosterItemRemoved);
这是我的实际插槽之一
void XmppConnection::connServerLookupHandler(const QString &server)
{
qDebug() << "Looking up Server: " << server;
return;
}
我无法弄清楚为什么Mac和Linux工作和Windows不知道。我已经考虑过编译器选项,但是我使用CMAKE,因此除非我的Linux GCC和MingW GCC之间存在巨大差异,否则我不知道为什么这会很重要。我正在使用Conne Call CALL显示的C 11功能。但是我适当地编译和链接,因此我假设C 11功能正如我预期的那样工作。有人有一个主意吗?
编辑:
我正在使用QT5.2.0 Mingw OpenGL。我正在使用QT5.2.0随附的mingw,即Mingw48 32.我正在与我的应用程序同时编译库,Iris,并使用CMake到Automoc,将其设置为链接依赖性,并包括正确的链接依赖标题。
edit2:包括我所有的连接电话。
事实证明,我缺乏窗户开发的事物,发现我在屁股上咬了我。因此,对于Windows,您需要在Windows上导出符号。
所以我添加了
/**
* @brief Allows for windows exported symbols
*
* Windows requries a special modifier to allow them to export correctly.
* This macro allows that while leaving Mac OS X and Linux alone.
*
* While Qt can tell us if it was make for WIN32, MAC, or LINUX, It cannot
* tell us if we are being statically or dynamically linked. That is why
* this is using the CMake variables instead of Qt
*/
#if defined (_WIN32)
// cmake makes this variable if your a shared library (projectname_EXPORTS)
#if defined(iris_EXPORTS)
#define IRIS_EXPORT Q_DECL_EXPORT
#else
#define IRIS_EXPORT Q_DECL_IMPORT
#endif /* iris_EXPORTS */
#else /* defined (_WIN32) */
#define IRIS_EXPORT
#endif
然后我会在每个
上使用它class IRIS_EXPORT ClassNameHere { ... }
IRIS_EXPORT void StaticFunctionNameHere(){...}
这解决了我的问题。
有关此信息的更多信息,请访问此处,这里或这里。
相关文章:
- Qt 信号/插槽问题
- Qt信号和插槽如果从QRunnable或其他线程调用,则不起作用
- C++Qt信号和插槽
- 使用std::move将std::unique_ptr作为qt信号参数传递
- 使用std::bind将Qt信号连接到插槽
- 如果代码中没有连接任何插槽,是否有理由发出Qt信号?
- 文档在哪里说明如果参数不是从末端删除参数,则无法从QT信号插槽连接中删除参数?
- 按钮组上的 Qt 信号未连接
- 通过排队的QT信号插槽连接发送QSHAREDPOINTERS的QVECTOR
- QT信号和插槽无法提供错误消息
- 如何监控Qt信号事件队列深度
- QT信号在虚拟机中不连接
- 为什么事件队列未处理我的QT信号
- 如何在打印机完成打印时从打印机获取Qt信号?
- 这是在Qt信号和插槽中使用参数调用函数的好方法吗?
- 删除 QObject 后 Qt 信号仍在触发
- Qt c++信号槽 - 清除信号所必需的
- 一个类中的QT信号/插槽,但从不同的线程发出
- QT:C 信号到QML连接
- 来自静态方法的QT信号