在 Linux Mint 18.1 上编译 LightScreen

在 Linux Mint 18.1 上编译 LightScreen

我在 Linux Mint 18.1 上编译声称与 Linux 兼容的应用程序时遇到问题。该应用程序被称为 Lightscreen。除了使用命令之外,一切都很顺利make

这是我到目前为止所做的命令过程:

我必须首先安装 QT 5.7,因为除非我使用旧版本的 lightscreen,否则它无法与任何其他版本一起使用,因为我会得到以下结果:

Project ERROR: Unknown module(s) in QT: x11extras

所以我继续安装了 QT 5.7,据称它在最近的更新中支持,这是输出:

nicholas@LinuxNick ~/bin/lightscreen $ /home/nicholas/.Qt/5.7/gcc_64/bin/qmake
Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
nicholas@LinuxNick ~/bin/lightscreen $ 

我怀疑一切都很好,因为没有错误消息,而是一般的项目消息,我继续说道。我运行 make 并出现了第一个错误。

In file included from tools/screenshot.cpp:45:0:
tools/screenshot.cpp: In member function ‘void Screenshot::save()’:
tools/screenshot.cpp:250:34: error: expected unqualified-id before numeric constant
             result = Screenshot::Success;
                                  ^
tools/screenshot.cpp:260:79: error: expected unqualified-id before numeric constant
   result = (QFile::rename(mUnloadFilename, fileName)) ? Screenshot::Success : S
                                                                     ^
tools/screenshot.cpp:260:79: error: expected ‘:’ before numeric constant
tools/screenshot.cpp:262:34: error: expected unqualified-id before numeric constant
             result = Screenshot::Success;
                                  ^
Makefile:5959: recipe for target 'screenshot.o' failed
make: *** [screenshot.o] Error 1

难道我做错了什么?我对在 Linux 上编译东西有点陌生,虽然我编译了很多程序,但我仍然没有掌握东西以及应该如何编译东西。分步指南会很有帮助,但不一定是这样,尤其是在不需要的情况下。

请帮忙,并提前致谢。

编辑:我现在遇到一个不同的问题。当我运行时make,这是输出:

g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DUGLOBALHOTKEY_NOEXPORT -DAPP_VERSION=\"2.5\" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_X11EXTRAS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SQL_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -I. -Itools/UGlobalHotkey -Itools/UGlobalHotkey -I../../.Qt/5.7/gcc_64/include -I../../.Qt/5.7/gcc_64/include/QtWidgets -I../../.Qt/5.7/gcc_64/include/QtMultimedia -I../../.Qt/5.7/gcc_64/include/QtGui/5.7.1 -I../../.Qt/5.7/gcc_64/include/QtGui/5.7.1/QtGui -I../../.Qt/5.7/gcc_64/include/QtX11Extras -I../../.Qt/5.7/gcc_64/include/QtGui -I../../.Qt/5.7/gcc_64/include/QtNetwork -I../../.Qt/5.7/gcc_64/include/QtSql -I../../.Qt/5.7/gcc_64/include/QtConcurrent -I../../.Qt/5.7/gcc_64/include/QtCore/5.7.1 -I../../.Qt/5.7/gcc_64/include/QtCore/5.7.1/QtCore -I../../.Qt/5.7/gcc_64/include/QtCore -I. -I. -I../../.Qt/5.7/gcc_64/mkspecs/linux-g++ -o os.o tools/os.cpp
tools/os.cpp: In function ‘QPair<QPixmap, QPoint> os::cursor()’:
tools/os.cpp:131:23: error: could not convert ‘QPoint(0, 0)’ from ‘QPoint’ to ‘QPair<QPixmap, QPoint>’
     return QPoint(0, 0);
                       ^
Makefile:5657: recipe for target 'os.o' failed
make: *** [os.o] Error 1

答案1

问题来自<X11/X.h>(仅在编译到Linux时包含)。它定义了以下宏:

#define Success 0

这会干扰同名的枚举成员Screenshot::Result::Success

要解决此问题,请打开 tools/screenshot.cpp,然后找到以下行:

#ifdef Q_OS_LINUX
    #include <QX11Info>
    #include <X11/X.h>
    #include <X11/Xlib.h>
#endif

在包含 Xh 之后,添加一个#undef Success.这会删除冲突的宏。

相关内容