Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

c++ - How to set Visual Studio 2012 RC Compiler for Qt instead of MinGW?

Windows 8 x86; Qt 4.8.2; Visual Studio Ultimate 2012 RC

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As far as I know Qt does not yet support Visual Studio 2012 RC. However, I managed to build Qt 4.8 with Visual Studio 2011 beta (the predecessor to Visual Studio 2012 RC - they just decided to rename it) myself. It required making some changes to Qt source code before compiling. Here are the steps I used:

  • Copy mkspecs/win32-msvc2010 to mkspecs/win32-msvc2012 and edit the qmake.conf file to specify _MSC_VER=1700.
  • Search for “msvc2010” in all files in the extracted directory and patch the ~10 places to also understand “msvc2012”
  • In a Visual Studio command shell, cd to tools/configure, run a previous version of qmake (which you need to already have), and then run nmake to update your configure.exe.
  • Search for “make_pair<” in all files and remove the template arguments.
    • This may not be required in VS 2012; in VS 2011-beta I got compile errors with make_pair when template arguments were specified.
  • In src3rdpartyjavascriptcoreJavaScriptCore untimeStructure.{h,cpp} change the make_pair calls to explicit JSC::StructureTransitionTableHash::Key constructor calls.
  • Edit src3rdpartyclucenesrcCLuceneconfigdefine_std.h to comment out _CL_HAVE_HASH_MAP and _CL_HAVE_HASH_SET
  • In a Visual Studio command shell, run the configure program that is installed with the source, e.g.: configure.exe -debug-and-release -platform win32-msvc2012 -opensource
    • [Optionally] add '-nomake demos -nomake examples' to the command line to save build time, and/or '-mp' to build in parallel
  • When the configure is complete, type nmake to start the build. This will build debug and release versions of all the libraries as well as release versions of all the tools (designer, etc.).

It took a little work but it worked for me and I now have dozens of Qt applications up and running, so I figured I'd share with anyone else who wants to build Qt 4.8.x on Visual Studio 11 (Visual Studio 2011 beta or Visual Studio 2012 RC.)

If this seems too complicated, just wait a bit; I'm sure Qt will support Visual Studio 2012 soon.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...