简体   繁体   English

"std::tr1 尚未声明"

[英]std::tr1 has not been declared

I'm trying nth time to compile qt from source, this time with option configure -release -platform-win32 but I'm getting errors:我正在尝试第 n 次从源代码编译 qt,这次使用选项 configure -release -platform-win32 但我遇到了错误:
在此处输入图像描述

Anyone knows how to fix it?任何人都知道如何解决它?
Thanks.谢谢。

"

You can run into this problem when compiling Qt with a MinGW compiler (maybe any gcc compiler) that defaults to compiling C++ programs with the C++11 standard enabled. 在使用MinGW编译器(可能是任何gcc编译器)编译Qt时,您可能会遇到此问题,该编译器默认编译启用了C ++ 11标准的C ++程序。

The 3rd party library JavaScriptCore tries to define some wrappers that 'normalize' has_trivial_constructor and related templates, but apparently it hasn't been been updated yet to deal with GCC's updates to incorporate the completed C++11 standard. 第三方库JavaScriptCore尝试定义一些“规范化” has_trivial_constructor和相关模板的包装器,但显然它尚未更新以处理GCC的更新以合并完整的C ++ 11标准。

The fix is to use a MinGW compiler that doesn't enable C++11 features by default, or to turn them off by editing mkspecs\\win32-g++\\qmake.conf to add the -std=gnu++98 option to C++ builds: 修复是使用默认情况下不启用C ++ 11功能的MinGW编译器,或者通过编辑mkspecs\\win32-g++\\qmake.conf来关闭它们以将-std=gnu++98选项添加到C ++建立:

QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98
#                               ^^^^^^^^^^^^

If you are using gcc 4.7 you have access to most of C++11 if you compile with -std=c++11 or -std=gnu++11 you can check out the supported features under std namespace here . 如果您使用gcc 4.7,则可以访问大多数C ++ 11,如果使用-std=c++11-std=gnu++11编译,则可以在此处查看 std命名空间下支持的功能。 tr1 sub namespace was for the draft which has been made standard now. tr1子命名空间用于草案,现已成为标准。

You can replace the preliminary std::tr1::has_trivial_constructor by the C++11 standardized std::is_trivially_constructible . 您可以用C ++ 11标准化的std::is_trivially_constructible替换初步的std::tr1::has_trivial_constructor std::is_trivially_constructible See http://www.cplusplus.com/reference/type_traits/is_trivially_constructible . 请参阅http://www.cplusplus.com/reference/type_traits/is_trivially_constructible

尝试(在#include <type_traits>的宏中包装)在TypeTraits.h中添加#include <tr1/memory>

I was able to resolve this very issue just by putting我能够解决这个问题只是把

QMAKE_CXXFLAGS += -std=gnu++98 QMAKE_CXXFLAGS += -std=gnu++98

in src\/script\/script.pro.在 src\/script\/script.pro 中。 I hope it doesn't cause any problems to have compiled some of the compilation units c++-11 and other gnu++98.我希望编译一些编译单元 c++-11 和其他 gnu++98 不会造成任何问题。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM