您的位置:首页 > 编程语言 > Qt开发

Qt编译 error: ‘std::tr1’ has not been declared

2018-01-24 10:17 495 查看

前言

在deepin 64 系统编译Qt(执行make)时报错:

In file included from ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastAllocBase.h:84:0,
from ../3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h:24,
from ../3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_exec.cpp:50:
../3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h:173:69: error: ‘std::tr1’ has not been declared
template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { };
^~~
../3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h:173:74: error: expected ‘{’ before ‘has_trivial_constructor’
template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { };
^~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h:174:68: error: ‘std::tr1’ has not been declared
template<typename T> struct HasTrivialDestructor : public std::tr1::has_trivial_destructor<T> { };
^~~
../3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h:174:73: error: expected ‘{’ before ‘has_trivial_destructor’
template<typename T> struct HasTrivialDestructor : public std::tr1::has_trivial_destructor<T> { };


查询得知是编译器参数设置不对,应该加上:
-std=gnu++98
参数

参考链接:

https://stackoverflow.com/questions/10354371/stdtr1-has-not-been-declared

解决办法:

1、 找出当前编译的版本,其目的是定位源码中 mkspecs/… 下面的编译选项设置目录

执行./configure 后,在输出文本中搜索
mkspecs
或者
Build type:
,可以找到对应的文件夹



或者:



2、打开
mkspecs/对应版本/qmake.conf


修改其中的
QMAKE_CXXFLAGS
为:
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98


如果该文件中不存在
QMAKE_CXXFLAGS
参数,则在该文件包含的头文件中查找。

例如:



该文件不存在
QMAKE_CXXFLAGS
参数,则打开
../common/linux.conf
../common/gcc-base-unix.conf
../common/g++-unix.conf
这三个文件。如果没有找到还需要递归的打开着三个文件中包含的文件。

../common/gcc-base.conf
(包含在文件
../common/gcc-base-unix.conf
中)文件中找到,并修改为如下所示。



../common/g++-base.conf
(包含在文件
../common/g++-unix.conf
中)文件中找到,并修改为如下所示。



然后执行:

To reconfigure, run ‘make confclean’ and ‘configure’.

make confclean

./configure (...)

make -j4


make install


编译安装完成。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐