I'm trying to build a C++ app on Windows using Qt.
My setup is:
Installed Vs2008,2010,2012
Installed Qt 5 RC1
Now when I #include and try to use std::unique_ptr it tells me that its not defined, so I looked in VS2010 headers and saw that _HAS_CPP0X needs to be defined, so I added it to the .pro as DEFINES += _HAS_CPP0X
This still had no effect, so I ctrl+clicked the #include memory only to find its using the memory header from:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
Which really doesn't have any std::unique_ptr in there!
Surely it should be looking at:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include ?
I figured I'd include memory via the full path but this still fails with errors in the included memory header itself relating to C++11 things such as move and rvalue references.
So what I'd like to know is:
Can Qt on Windows use C++11 features supported by Vs2010?
If yes then how?
If no then I'm very disappointed as developing a cross platform Qt 5 app on Linux means its not cross platform since its impossible to build it for any other platforms!
Edit:
Just so the solution to this is clear: Download the source of Qt5 and build it with MinGW and you'll be all set (inc the C++11 pro option in the accepted answer).
You can simply put:
CONFIG += c++11
in your .pro file. But upgrading your compiler to a recent g++ or clang is highly recommended.
I'm running QT Creator 2.6.0 so assuming the option menu hasn't changed if you go to Tools > Options > Build & Run and then look for the Compilers tab you should see a list of Automatically detected compilers, hopefully including Microsoft Visual C++ Compiler 10.0. If not it can be manually added.
As for C++11 support, if you are using cmake and imported the project into QT Creator as such you can add this to your cmake file: set(CMAKE_CXX_FLAGS "-std=c++0x")
If you are using qmake then per the manual set QMAKE_CXXFLAGS += -std=c++0x
Edit:
That said Visual Studio 2010 (Visual C++ 10.0) turns on c++11 support by default although it should be noted it is only a subset, here is a related question.
NO
Can Qt on Windows use C++11 features supported by Vs2010?
You have to get Visual 2012 for that.
If no then I'm very disappointed as developing a cross platform Qt 5 app on Linux means its not cross platform since its impossible to build it for any other platforms!
On mac, use XCode 4 compiler CLang 2 and on any platform a compiler based on GCC 4.7 works
Related
I am building a GUI application in which I have to use Visual Studio 2010 build tools. I was told that the correct qt version to use with this VS version is 4.8. I've downloaded Qt 4.8.0 using this link:
https://download.qt.io/archive/qt/4.8/4.8.0/
And I made this version the default in the VS Qt options menu. However, when I try to create a new visual studio project, all of the module options are greyed out.
Which in turn makes it impossible to create the project because upon clicking "next", the "Finish" button is also greyed out. Any Idea of what's going on??
With pre-compiled binaries (that is, you don't have to compile qt yourself) you can use Qt 5.5.1 with VS2010 that you can get from here.
After that, i would create a simple project using qmake and specifying
TEMPLATE = VCAPP
that will tell the qmake (see docs) to generate a .vcprojx file that you can use from VS2010.
Latest Qt version that supports VS2010 is 5.6.3 IIRC, however mind you that even that version is now EOL. (March 2019).
You should try to upgrade to 5.9 or 5.12 (however i am not sure that VS2010 will be able to support those since they rely pretty heavily on c++11 that VS2010 supported very lightly)
P.S. If you'r stuck with Qt4 then greatest version is 4.8.7 (VS2010 supported) that you could get from here
I'm using the following compilers:
MinGW 4.9.2 32Bit
Microsoft Visual C++ Compiler 12.0 (x86)
with the following debuggers, respectively:
GNU gdb 7.8 for MinGW 4.9.2 32Bit
CDB (\Windows Kits\8.1\Debuggers\x86\cdb.exe)
with Qt Creator 3.5.0 and Qt 5.4.2.
What I would like to see is the pretty printed ("high level") interpretation of a QHash within the debugger watch view. See e.g. this post: https://blog.qt.io/blog/2009/06/22/peek-and-poke/
The pretty printing works with gdb + MinGW but not with CDB + MSVC2012. In the latter, I can only see the 'low level' interpretation.
What do I have do to get this work with CDB + MSVC2012 too?
You will need to add a correct debugging addin dll into the visual studio installation directory C:\Program Files\Microsoft Visual Studio ${num}\Common7\IDE or preferably the add-in directory ( default is %USERPROFILE%\Documents\Visual Studio ${num}\Addins).
Qt already provide a complete set of tools for MSVC integration which can be built from one of the qt git vstool project.
There is a wiki which provide a step by step guide to make it work. Basically :
get the project from repository
create the solution files
build the correct solution, as there is one for each pair Qt4\Qt5 x VsVersion
Copy the target dll to the addin directory.
Hi I have updated visual studio to 2015 version and I have Qt msvc2013. Qt says that no compilers can make code for this version of Qt, (Qt detected compilers from visual studio). How can I make it working without installing VS2013?
You cannot mix C++ compiled with different major versions of the Microsoft Visual C++ compilers. So you need to either get a version of Qt for Visual Studio 2015, or compile your own one.
At this time, there is not yet an official build of Qt for Visual Studio 2015 available (this is planned for Qt 5.5.1 5.6.0). If you want to try compiling yourself, https://wiki.qt.io/Building_Qt_5_from_Git is a comprehensive guide. You should try either the 5.5 branch (if you get the Qt sources from git), or the 5.5.0 source packages. You should be able to get help e.g. on the qt-interest mailing list.
Adding a new mkspec is pretty simple, just copy the win32-msvc2013 and rename it to win32-msvc2015, then modify and use that one.
Second thing to do is not try to link against 2013 built libraries. If 2015 follows the same pattern as the older one, mixing libraries from different VS version is not possible.
Last thing, before adding icu, OpenSSL and MySQL you rather try to build Qt with the default parameters.
Qt's current development version is 5.6.
It is in beta and there are prebuild binaries for msvc2015.
Link to Qt Development Binaries
I cant use std::wstring_convert in Qt 5.1, because it said me that <codecvt> : No such file directory. What can I do? I don't know... this code is working at the MSVC 2013.
QtCreator is just a front-end that allows you to edit your source files, it does not contain a compiler. On Windows you need either MinGW or Visual Studio to compile code.
If you want to use Qt 5.1 with Visual Studio 2013, you would have to compile Qt yourself. Digia provides builds for Visual Studio 2010 and 2012. You can find the latest version of Qt here or an old release here.
My advice would be to install Visual Studio 2012 and download a VS2012 build of Qt. Then go to Tools > Options > Build & Run > Kits, click the Add button on the right (or modify the existing one as it probably won't work anyway). Set the compiler to "Microsoft Visual C++ compiler 11.0 (amd64)" if you downloaded the 64 bit version of Qt or "(x86)" if you downloaded the 32 bit version.
Then set the debugger to cdb.exe and the Qt version to the one you just downloaded (if you don't see it, go to the Qt Versions tab at the top, add it, click Apply and the go back to Kits and it should be there). Click ok and your kit should be ready! Make sure that you don't have a warning signal that would point out a potential mistake.
Now open your project and go to the Projects tab (Ctrl + 5) and make sure your project is using the correct Kit.
You should now be all set up properly.
Additionally, if you don't want to install Visual Studio 2012 and want (or have to) work with VS 2013, you can use the Qt 5.3 BETA builds located here. Please note that these builds are in beta and shouldn't be used in production code, if you want to use VS2013 with Qt in production code I would recommend to build Qt 5.2.1 with VS2013, it's not that hard but it can take a while.
You are missing this in your project file:
CONFIG += c++11
You need to make sure that your GCC version (brought to you by mingw) supports that feature though. It is possible that you are using an old version where it was not supported.
Not long time ago I started to have some fun with c++ and Qt seemed the right place for a noob to begin.
I installed Qt 5.0.0 with Qt Creator 2.5 and Visual Studio 2010 Express for the compiler and everything was ok, I was able to write a simple application and run it.
From what i've seen Visual Studio 2012 offers almost all features of c++11 and my question is: If i install the new Qt 5.0.2 + Qt Creator 2.7 and visual studio 2012 will i be able to use it as a compiler and use all the features presented here (lambdas, smart pointers, move semantics,etc) ?
PS: I use Windows 7 64 bit
Yes, Creator supports the MSVC2012 compiler and the features depend on the compiler, not Creator. This is how I've been using Qt for a while.
Note that the IDE itself might not have support for some new C++11 features when it comes to checking your code, but even if you get errors or warnings, as long as your code is valid, it will compile.