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

https://blog.csdn.net/baidu_33850454/article/details/79147161

在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> { };
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

查询得知是编译器参数设置不对,应该加上:-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 
  • 1
  • 2
  • 3
  • 4
  • 5
make install
  • 1

编译安装完成。

posted @ 2018-08-23 17:22  撑伞的猫先生。  阅读(2783)  评论(0编辑  收藏  举报