std::tr1 has not been declared

11,850

Solution 1

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.

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.

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:

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

Solution 2

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. tr1 sub namespace was for the draft which has been made standard now.

Solution 3

You can replace the preliminary std::tr1::has_trivial_constructor by the C++11 standardized std::is_trivially_constructible. See http://www.cplusplus.com/reference/type_traits/is_trivially_constructible .

Share:
11,850
smallB
Author by

smallB

Updated on June 26, 2022

Comments

  • smallB
    smallB almost 2 years

    I'm trying nth time to compile qt from source, this time with option configure -release -platform-win32 but I'm getting errors:
    enter image description here

    Anyone knows how to fix it?
    Thanks.