13

IN A NUTSHELL:

  1. My 64-bit Qt build doesn't have C++11 support.
  2. My Qt build with C++11 is 32-bit.
  3. Qt5 using the online installer is 32-bit
  4. Despite having dedicated the last 3 days of my life to this, I can't get 64-bit Qt5 to build from source.

Help! Something must be incompatible in my environment, but what could it be?


So, I need to develop 64-bit Qt apps with C++11 on Windows. I've found threads/guides here, here, here, here and here, and none of them work or apply, though I note the second of these let me build Qt 4.8.3 with C++11 support (but 32-bit). The third one looks more complicated than it should be and also involves building with VS 2010, which seems like part of the problem, so I haven't tried it. I have also wasted a lot of time trying to build previous versions with different compilers, like mingw and clang, so I'm pretty sure that cl is what I need to use.

Basically, I've gotten to the point where I can build Qt4.8.3 and execute 64-bit apps from within QtCreator 2.6.1, but I can't get full C++11 support. It finds only cl from VS 10.0 which has only very limited C++11 support. Figuring out how to get it to use cl from VS 11.0 would be one solution to my problem. But when I try

QMAKE_CXX = C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl

the build fails with a jom Error 2, and if I select the option for building with nmake I get a similar error.

Qt 5 should have full C++11 support. But when I try to build it myself from source, it fails. The reason for this seems to be that despite running configure/make from the VS2012 x64 Cross Tools command prompt, specifying -platform win32-2012 in the configure step, and specifying QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32 as per
this guide, in both the win32-msvc2010 and win32-msvc2012 mkspecs, it still builds with the cl from VS 2010 and that is causing some kind of conflict. Here is my configure command:

configure -static -debug-and-release -confirm-license -opensource -nomake tests -nomake exampmles -opengl desktop -no-libjpeg -platform win32-msvc2012

And here's the linker failure when I try to build:

Here is the output from my build failure:

At the end of the top 2 paragraphs you can see that msvc-2010 is being included, and earlier in the console output (not shown) there is -D_MSC_VER=1600 in the moc commands.

So I'm at a loss, can anyone help?

Edit: I had stated that I was building 64-bit apps with Qt5, actually I'm able to build 64-bit apps (w/o C++11 support) off a build of Qt 4.8.3. If I try this with Qt5, I get this error:

LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

So this leads back to compiling Qt5 in 64-bit mode, which I can't seem to do.

Community
  • 1
  • 1
Matt Phillips
  • 9,465
  • 8
  • 44
  • 75
  • I don't think that the Qt libs themselves have anything to do with C++11 support, you don't need a special build of the Qt DLLs/libs. – sashoalm Jan 20 '13 at 18:00
  • @satuon I think compatibility is required actually, but if it's not, then I should be able to use C++11 with the 4.8.3 64-bit build I have. But then like I say it only compiles with cl from VS 10.0. If you can tell me how to get my 64-bit build to see C++11 that would solve my problem. – Matt Phillips Jan 20 '13 at 18:10
  • What I mean is, the Qt libraries are just DLL/lib files you link to, plus a custom preprocessor. Qt is not a C++ compiler. C++11 support depends on the compiler you use, which on Windows is either MinGW or MSVC. Or do you mean Qt Creator (the IDE)? In this case, since you're on windows, you can use Visual Studio instead - Qt has a plugin for that. It allows you to convert a Qt Creator project to VS .sln file. – sashoalm Jan 20 '13 at 18:13
  • @satuon Have you ever used Qt libs from one c++ version, for a Qt app build in another? My experience is that they need to be the same, even though in general indeed the target shouldn't care about what C++ version associated libs were compiled with. I'll check out the plugin but I haven't needed this for my Qt projects yet and I'm not familiar with VS2012. – Matt Phillips Jan 20 '13 at 18:29
  • @satuon Also I'm compiling with VC++ 11.0 x86 for version that works with C++11, it won't let me use the x64 version with a 32-bit Qt build. (Naturally, I guess.) Windows SDK 7.1, amd64 for the version that works with 64-bit. – Matt Phillips Jan 20 '13 at 18:32
  • @satuon Right so when I try to compile against the 64-bit version with VC 11.0 x86_amd64 I get `error: LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in main.obj`. (1700 corresponds to 11.0, 1600 to 10.0). So the Qt libs do actually have to be consistent with the target, it looks like. – Matt Phillips Jan 20 '13 at 18:42
  • Ah, I get it now. Yes, a 64-bit exe can't use 32-bit DLLs and vice versa, of course. But x64/x86 has nothing to do with C++11, they seem to be unrelated problems. – sashoalm Jan 20 '13 at 18:42
  • OK, it seems that the Qt libs themselves need to support C++11 features in their API, so I was wrong, and your question is right. You do need a special Qt build that supports C++11. I have no idea how to solve your problem, though. – sashoalm Jan 20 '13 at 20:04
  • @satuon Well then, maybe +1 so it gets more visibility? :) – Matt Phillips Jan 20 '13 at 20:29
  • @satuon Well it looks like the VS Add-in is for [Premium owners only](http://qt-project.org/downloads#qt-other) which I am not :(, and I couldn't find it in the repository or ftp archive... I don't suppose you have a link or otherwise know how to get it? – Matt Phillips Jan 20 '13 at 22:20
  • 2
    Have you looked at http://stackoverflow.com/q/10863466/492336 – sashoalm Jan 21 '13 at 06:18
  • @satuon Thanks for that, no I hadn't. It looks like the second link I described above, but with some differences. Indeed I am now trying to go back to the version I actually was able to build in 64-bit mode (4.8.3) and rebuild that so that it has C++11 support, fingers crossed. – Matt Phillips Jan 21 '13 at 06:26

3 Answers3

2

Finally got a 'good enough' solution by going back and rebuilding 4.8.3 in 64-bit mode, this time ensuring that it was built with C++11 support. Since a solution involving Qt5 is what would be ideal, I'll leave this open for awhile to see if anyone can figure out how to do that.

Importantly, I note that I successfully built 64-bit, C++11-supporting 4.8.3 from the same prompt I had been using to try to build 5.0. Just changed directories. So same environment, everything. And I also have downloaded all the extra prereqs required for Qt5.

Matt Phillips
  • 9,465
  • 8
  • 44
  • 75
2

You can find prebuilds of Qt 5.0.1 SDK with 64bit support here: http://releases.qt-project.org/digia/5.0.1/latest/

Tested and working :)

0

I found Qt 4.8.5 windows version qt-win-opensource-4.8.5-vs2008.exe at https://download.qt.io/archive/qt/4.8/4.8.5/ for VC++ projects.

Pabitra Dash
  • 1,461
  • 2
  • 21
  • 28