Compiler Qt Creator 2.6.1 + Qt 5 + C ++ 11 + MSVC2010

I am trying to create a C ++ application on Windows using Qt.

My setup:

  • Installed Vs2008,2010,2012
  • Installed Qt 5 RC1

Now when I #include and try to use std :: unique_ptr, it tells me that it is not defined, so I looked in the VS2010 headers and saw that _HAS_CPP0X needs to be defined, so I added it to .pro as DEFINES + = _HAS_CPP0X

It still didn't affect, so I pressed Ctrl + clicked #include memory to find it using the memory header:

C: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ VC \ include

Actually there is no std :: unique_ptr!

Of course, he should look at:

C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC \ include?

I decided that I would include the memory through the full path, but this still fails with errors in the included memory header related to C ++ 11 things, such as move links and rvalue.

So I would like to know:

  • Can Qt on Windows use the C ++ 11 features supported by Vs2010?
  • If so, how?
  • If not, then I am very disappointed that developing a cross-platform Qt 5 application on Linux means it is not a cross platform, since it is impossible to build it for any other platforms!

Edit:

Just such a clear solution: download the Qt5 source and create it using MinGW, and everything will be ready (including the C ++ 11 pro option in the accepted answer).

+4
source share
3 answers

You can simply put:

CONFIG += c++11 

in your .pro file. But it is highly recommended that you upgrade your compiler to recent g++ or clang .

+2
source

I run QT Creator 2.6.0, so if the options menu has not changed, if you go to Tools> Options> Build and Run, and then find the Compilers tab, you will see a list of automatically detected compilers, I hope including Microsoft Visual C ++ Compiler 10.0. If not, you can add it manually.

As for C ++ 11 support, if you use cmake and import the project into QT Creator as such, you can add this to your cmake file: set (CMAKE_CXX_FLAGS "-std = C ++ 0x")

If you use qmake and then the manual , set QMAKE_CXXFLAGS + = -std = C ++ 0x

Edit: However, Visual Studio 2010 (Visual C ++ 10.0) includes support for C ++ 11 by default, although it should be noted that this is just a subset, here is a related question .

0
source

NO

Can Qt on Windows use the C ++ 11 features supported by Vs2010?

For this you will need Visual 2012.

If not, then I am very disappointed that developing a cross-platform Qt 5 application on Linux means it is not a cross-platform, since it is impossible to build it for any other platforms!

On mac, use the Xcode 4 CLang 2 compiler and on any platform, the GCC 4.7 based compiler works

-1
source

All Articles