【问题标题】:Issue Building new application with QT 5.8 Ubuntu使用 QT 5.8 Ubuntu 构建新应用程序的问题
【发布时间】:2017-01-28 03:22:25
【问题描述】:

我已经使用 QT 的安装程序(在线安装程序)在 Ubuntu 16.04 中安装了 QT 5.8,安装后,我尝试使用 MainWindow 的基本代码创建一个 GUI 应用程序,它为您提供作为起点但无法编译。

我在 Windows 10 和 Zorin OS(基于 Ubuntu 的发行版)的另一台机器上做了完全相同的事情,并且运行良好。

尝试编译时出现以下错误:

18:37:57: Running steps for project aLAL...
18:37:57: Configuration unchanged, skipping qmake step.
18:37:57: Starting: "/usr/bin/make" 
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../aLAL -I. -I/home/twistx77/Qt/5.8/gcc_64/include -I/home/twistx77/Qt/5.8/gcc_64/include/QtWidgets -I/home/twistx77/Qt/5.8/gcc_64/include/QtGui -I/home/twistx77/Qt/5.8/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/home/twistx77/Qt/5.8/gcc_64/mkspecs/linux-g++ -o main.o ../aLAL/main.cpp
In file included from /home/twistx77/Qt/5.8/gcc_64/include/QtCore/qcompilerdetection.h:996:0,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtCore/qglobal.h:97,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtGui/qtguiglobal.h:43,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/qtwidgetsglobal.h:43,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/qmainwindow.h:43,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/QMainWindow:1,
                 from ../aLAL/mainwindow.h:4,
                 from ../aLAL/main.cpp:1:
/usr/include/c++/5/utility:213:5: error: ‘qtruct’ does not name a type
     qtruct _Build_index_tuple
     ^
/usr/include/c++/5/utility:219:12: error: ‘_Build_index_tuple’ is not a class template
     struct _Build_index_tuple<0>
            ^
/usr/include/c++/5/utility:220:5: error: explicit specialization of non-template ‘std::_Build_index_tuple’
     {
     ^
In file included from /usr/include/c++/5/bits/stl_map.h:63:0,
                 from /usr/include/c++/5/map:61,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtCore/qmetatype.h:55,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtCore/qobject.h:54,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/qwidget.h:45,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/qmainwindow.h:44,
                 from /home/twistx77/Qt/5.8/gcc_64/include/QtWidgets/QMainWindow:1,
                 from ../aLAL/mainwindow.h:4,
                 from ../aLAL/main.cpp:1:
/usr/include/c++/5/tuple:1074:29: error: ‘std::_Build_index_tuple’ is not a template
       typedef typename std::_Build_index_tuple<std::tuple_size<
                             ^
/usr/include/c++/5/tuple:1075:54: error: typedef name may not be a nested-name-specifier
  typename std::remove_reference<_Tp>::type>::value>::__type __type;
                                                      ^
/usr/include/c++/5/tuple:1075:54: error: expected ‘;’ at end of member declaration
/usr/include/c++/5/tuple:1075:61: error: declaration does not declare anything [-fpermissive]
  typename std::remove_reference<_Tp>::type>::value>::__type __type;
                                                             ^
/usr/include/c++/5/tuple: In constructor ‘std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>)’:
/usr/include/c++/5/tuple:1160:16: error: expected nested-name-specifier before ‘_Build_index_tuple’
       typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
                ^
/usr/include/c++/5/tuple:1160:16: error: expected ‘(’ before ‘_Build_index_tuple’
/usr/include/c++/5/tuple:1161:16: error: expected nested-name-specifier before ‘_Build_index_tuple’
       typename _Build_index_tuple<sizeof...(_Args2)>::__type())
                ^
/usr/include/c++/5/tuple:1161:16: error: expected ‘(’ before ‘_Build_index_tuple’
Makefile:877: recipe for target 'main.o' failed
make: *** [main.o] Error 1
18:37:58: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project aLAL (kit: Desktop Qt 5.8.0 GCC 64bit)
When executing step "Make"
18:37:58: Elapsed time: 00:01.

我试图在互联网上寻找解决方案,但我无法弄清楚。

任何帮助将不胜感激。

【问题讨论】:

    标签: qt ubuntu compiler-errors


    【解决方案1】:

    您的 C++ 标准库头文件 utility 似乎已损坏:

    /usr/include/c++/5/utility:213:5: error: ‘qtruct’ does not name a type
         qtruct _Build_index_tuple
    

    我会尝试在该文件中将qtruct 更改为struct。或者你可以重新安装标准库

    【讨论】:

    • 谢谢,但这无济于事。我认为这个问题可能与我尝试从控制台运行 QtCreator 时收到的这条消息有关“没有在套件“Desktop Qt 5.8.0 GCC 64bit”中为“C”设置工具链”虽然我已经检查过了似乎编译器被正确地自动检测到了。
    • @twistx77:当你尝试它时发生了什么? (1) 没有,因为您无法编辑系统标题。 (2) 一些其他错误消息(如果是,是什么?) (3) 其他一些...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多