c++ - Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE -


how qt5 download , integrate visual studio 2012? of problems encounter, , how solve problems?

update re. visual studio 2013

successes reported visual studio 2013 well, , notes being maintained vs 2013.

also note the focus of question on building qt visual studio. there notes integrating visual studio ide

this method tested work on visual studio 2013. pre-built binaries using visual studio 2012 , 2013 available here, including opengl versions.

step 1: setup

  1. download , install rapidee here. rapidee windows environment variables editor. extremely useful rest of process (and in general).

  2. install directx 11 sdk. part of windows 8 sdk, first have install directx 10 sdk, can here (but see warning in next sentence). if have visual c++ 2010 redistributable package installed, , (it automatically installed along vs 2010), follow steps outlined here assist directx 10 installation. once have directx 10 sdk installed, download , install windows 8 sdk here, contains directx 11 sdk. yes, pain, unless know have directx 11 sdk, qt build fail.

  3. install python windows (i've heard 2.6+, working 3.3) python.org or anaconda python.

  4. install perl windows activestate.


step 2: gitting (and building) qt5 (yes, that means git)

  1. follow installation guide windows @ qt-project website.

    summary

    to summarize details above link , following notes (please see following notes if have errors; might answered):

    • uninstall avast (if have installed) avoid build errors. yes, literally means uninstall it. remove 100% system. deactivating will not work. see detailed notes below.

    • note first steps: not use smartgit first git pull, below (unless know you're doing), smartgit's defaults pull everything, , that's not want.

    • git windows must installed.

    • decide want put qt installation, , cd directory contain new installation command prompt window. (because process fragile , error-prone, put directly in c:, not necessary).

    • from above directory, execute:

      git clone git://gitorious.org/qt/qt5.git qt5

      this fast. once complete, should on 'stable' branch, can run git checkout stable after cding newly-created qt5 directory, sure. using git checkout 5.4.1 confirmed work vs2013 64-bit.

    • close out of current command prompt window (if it's not visual studio command prompt window) before proceeding next step. make sure you're using visual studio command prompt window in next steps.

    • next run 32-bit (x86) or 64-bit vs tools command prompt (depending on whether you're building qt5 32- or 64-bit). access this, must find through start menu - go program files -> [microsoft] visual studio 2012/2013 -> visual studio tools, , you'll see in there funny name; name should include phrase native tools; 32-bit version have x86 in name , 64-bit version have x64 in name.

    • cd newly-created qt5 directory step above.

    • from within visual studio command prompt, remainder of qt submodules must downloaded:

      perl ./init-repository --no-webkit

      it takes kind of while execute step, because has download lot, it's not terrible on decent connection.

    • then download remaining optional submodules init-repository not download - smartgit works starting @ stage (see comments below).

    • once download of qt complete, following command prepares build environment (it should executed using [32|64] vs native tools command prompt):

      configure -developer-build -opensource -confirm-license -mp -nomake examples -nomake tests -debug-and-release -c++11 -no-warnings-are-errors -platform win32-msvc2012.

      notes on command line: c++11 option might not necessary vs2012 compiler, works vs2013; -no-warnings-are-errors necessary in case errors on 64-bit automatic build of angle; -platform automatically set win32-msvc2012, default 32-bit build of qt used, , -platform not need supplied @ command line (even if have previous versions of vs installed). vs2013, use -platform win32-msvc2013.

      it takes few minutes execute step, it's not bad.

    • finally, command build qt on system (also run within vs native tools command prompt) simply:

      nmake

      expect wait hours build complete. if specified output folder -prefix (see notes below), use nmake install, otherwise that's it.


notes:

general notes

in case you're confused above-linked documentation, fyi angle library used (by default) instead of opengl, , that's why had install directx 11, above.

make sure use vs native tools command prompt run commands above link (that is, perl .\init-repository --no-webkit, configure, , nmake). use [32|64] bit command prompt (x86 or x64), depending on whether building qt 32-bit or 64-bit. if install perl command prompt open (make sure in path), need restart command prompt perl recognized command.

when running "init-repository" (from steps in above link), it's not clear documentation, must execute via perl; i.e. perl ./init-repository --no-webkit. configure , nmake commands, however, called directly.

one useful option pass configure -mp, causes qt build on multiple cores in parallel, speeding (long) build time.

to specify output folder add -prefix [outfolder] configure command. example, use -prefix %cd%\output\x64\vc12 suitable output (sub)folder 64-bit visual studio 2013 (12.0) build.


unicode support (icu)

if want unicode support (via icu), pay special attention instructions noted within link above. in summary, icu must built scratch in vs 2012, prebuilt icu binaries windows vs 2010. building in vs 2012 painless - locate icu solution (.sln) in <icuroot>\icu\source\allinone, , build in both debug , release mode (either in 32-bit or 64-bit mode, depending on mode you're building qt in - not build in other bitness, because icu overwrite output folder binaries). (the qt build process locate debug vs. release build of icu.) should build without errors. then, add path <icuroot>\lib string entry in (probably) new windows environment variable called "lib" (you can use rapid ee this; make lib "expandable string" in rapidee though there's 1 entry), , add path <icuroot>\include string entry in (probably) new windows environment variable called "include". (note: adding these paths path variable not work.) after qt built, can remove of these entries you've added. also, add runtime path icu dll's (<icuroot>\bin) environment's path variable, or qt build process (specifically, when uic.exe runs) give deceptive , misleading error. finally, on configure command line (below), sure add -icu additional command-line parameter.

icu failure:

currently, there seems bug building qt5 vs2012 compiler when icu enabled. specifically, qtbase\src\corelib\codecs\qtextcodec.cpp line 688 (qt5 v5.02) fails return codec codec name "us-ascii" (the codec null), causing "lrelease.exe" crash when trying dereference codec later (i have lost track of file/line number, obvious dereference of null codec variable). unfortunately, means knowledge, webkit cannot built (at least the) 32-bit build of qt5 vs2012 compiler, because webkit requires icu.

if able build qt5 vs2012 compiler icu enabled, please update wiki saying so.

icu clarification:

if have icu in path, qt automatically built it. in other words, flag "-icu" there implicitly. however, causes error "lrelease.exe" mentioned above. way around add flag, -no-icu configure command


additional submodules

if want submodules in addition default submodules, can use smartgit (or command line) after complete init-repository command. smartgit perhaps easiest, because not need copy path command line, can use user interface directly.

warning: not download optional qlalr submodule, not build in combination overall qt build, , not necessary users of qt, used internal qt development.

warning: shell command line, followed perl .\init-repository --no-webkit, must used (not smartgit); these steps download default qt submodules. must not use smartgit clone , download git files git://gitorious.org/qt/qt5.git because smartgit not handle submodules properly. instead, open standard windows shell command prompt (using command-prompt application, not vs tools command prompt), , (assuming git installed on system; smartgit installation might or might not automatically; if not, go git windows , install directly) type git clone git://gitorious.org/qt/qt5.git directly command line; perhaps follow git checkout stable (i'm not sure if branch checked out default); follow command line perl .\init-repository --no-webkit pull down default repositories (except webkit, requires icu , icu seemingly cannot built in 32-bit qt5 vs2012; see comments).

the steps downloading necessary qt source files therefore are: 1. use windows command line execute initial git clone git://gitorious.org/qt/qt5.git; 2. execute perl .\init-repository --no-webkit within vs tools 2012 command prompt; , optionally 3. use smartgit (from above link) (or equivalent) "open existing project" (choose qt5 root folder) , pull within smartgit download non-default repositories (but not download qlalr). that's it; have necessary , optional qt files (including submodules) on system.

if discovers other optional submodules fail build and/or internal use (besides qlalr), please update wiki specify them.

in general, default submodules obtained via perl .\init-repository --no-webkit sufficient. if know, or later find out, other (non-default) modules, can add them later.


general problems

if @ point error saying command "python" (or similar) not recognized, check folder containing python.exe (or appropriate .exe) part of path variable. if not, add (use rapidee noted above convenience) , try doing again. if there, make sure have restarted command prompt after addition of command path.

two other path-related issues important note (quoted documentation associated link above): "make sure perl executable found in path before perl executable provided msysgit, since latter outdated"; , "you might not able build if sh.exe in path (for example due git or msys installation). such error indicated qt5-srcqtbasebinqmake.exe: command not found , alike. in case, make sure sh.exe not in path. have re-configure if installation configured."

during process, may encounter error using nmake on file. if do, go directory , force build problem file. begin nmake process on qt5 again.


specific problems

warning: may need disable antivirus software and sandboxing during qt nmake process (and, safe, throughout entire process). internally, qt executes number of executables antivirus programs can interfere (sometimes silently). in particular, if have sandboxing software, sure disable sandboxing.

warning: avast! sandbox users: avast sandbox has bug in when disable avast's auto-sandbox, sandbox not turn off , silently sandbox resource files automatically created qt's rcc program during qt's build process. qt build fails user has installed avast autosandbox feature, auto-sandboxing turned off. way overcome issue uninstall avast! system before building qt. can reinstall avast! after qt build complete.


the compilation of qt5 can take long time (hours, -mp multithreading option). patience.


step 3: integrating qt5 visual studio 2012

  1. download , install visual studio qt5 addin. in "other downloads" section near bottom of page, , not work visual studio express.

  2. open visual studio 2012, , go qt options (it's under "qt5" on top menu bar).

  3. in qt versions tab, check see if qt5 there. if not, click add, choose version name (probably name such 5.x.x), , navigate folder containing qmake.exe (usually c:\qt\qt5\qtbase).

  4. exit qt options dialog.

  5. create new visual studio project. when see new project dialog, should see qt5 projects template option.

  6. once have new qt project, right click on , select "convert qmake generated project". build project, right click on again , select "convert project qt add-in project". build again, run. should have working qt project.


add qt5 existing visual studio 2012 vc++ project

this section may or may not work you. if run problems or have additional/better solutions, please leave comment or edit appropriate step.

  1. right-click on project in vs, , choose "unload project". right click on project again, , select "edit [project name].vcxproj". opens project file can add qt5 it.

  2. go down global propertygroup, , add or change <keyword> qt4vsv1.0.

  3. reload project, right-click , select "convert project qt add-in project"

  4. wait conversion finish (it not take more couple seconds), choose qt5>project settings. go modules tab, , check modules project rely on (the basic ones core, widgets, , gui).

  5. following steps here, add directory $(qtdir)\include.


    notes:

    if @ time including windows.h, need #define nominmax before doing prevent conflict qdatetime.h.

    once above steps done, can make project usable qt creator selecting qt5>create basic .pro file.


ending notes: if have question related information contained in guide, please post new question (not answer here), , answer or link answer may added.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -