在Ubuntu的Qt5应用程序中链接libqxt

Linking libqxt in a Qt5 application on Ubuntu

本文关键字:链接 libqxt 应用程序 Qt5 Ubuntu      更新时间:2023-10-16

我在Qt5应用程序中链接libqxt有问题。

我在文档中编写了一个类似示例的代码,但我有错误。

QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(this);
connect(shortcut, SIGNAL(activated()), this, SLOT(newScreenshoot()));
shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));

我正在使用Qt 5.0.1:

damian@damian-Lenovo-B560:~$ qmake --version
QMake version 3.0
Using Qt version 5.0.1 in /usr/lib/i386-linux-gnu

和最新的libqxt-dev来自Ubuntu 13.04存储库。

我有以下链接错误:

/home/damian/Dokumenty/Programowanie/QShot/mainwindow.cpp:20: error: undefined reference to `QxtGlobalShortcut::QxtGlobalShortcut(QObject*)'
/home/damian/Dokumenty/Programowanie/QShot/mainwindow.cpp:22: error: undefined reference to `QxtGlobalShortcut::setShortcut(QKeySequence const&)'

我现在在Ubuntu 13.10上遇到了类似的问题,我已经成功地编译了我的应用程序。问题是在添加日志引擎

时收到SIGSEGV。
QxtBasicFileLoggerEngine *dbg  = new QxtBasicFileLoggerEngine("debug.log");
// qxtLog takes ownership of dbg - no need to manage its memory
qxtLog->addLoggerEngine("dbg", dbg);

为了做到这一点,我从命令行使用QT4编译了所有内容(不要使用qmake,它默认使用qt5):

qmake-qt4 
make

所以这似乎确实是qt5库与qt4库的奇怪组合(libqxt似乎是用/for qt4编译的)。不幸的是,为了在Ubuntu上编译这个项目,我没有任何其他的选择,只能使用qt4。我不知道canonical是否提出了问题。

希望这节省了一些麻烦,消除了一些挫折。我很惊讶几乎没有人抱怨这个问题。