{"id":54,"date":"2011-03-06T17:13:45","date_gmt":"2011-03-06T15:13:45","guid":{"rendered":"https:\/\/www.npcglib.org\/~stathis\/blog\/?p=54"},"modified":"2012-05-26T01:25:05","modified_gmt":"2012-05-25T23:25:05","slug":"qt-shadow-build-with-visual-studio","status":"publish","type":"post","link":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/","title":{"rendered":"Qt Shadow build with Visual Studio"},"content":{"rendered":"<p>A &#8220;shadow build&#8221; is an out-of-source build, where the source code is kept in one place and the build tree in another. I use this method to compile Qt on windows with Visual Studio (as of writing this post with VS2010).<\/p>\n<hr\/>\n<h3>Preparation<\/h3>\n<p>First download the latest Qt source code package. I usually download the latest <code>qt-everywhere-opensource-src-x.x.x<\/code> from <a href=\"http:\/\/get.qt.nokia.com\/qt\/source\/\">http:\/\/get.qt.nokia.com\/qt\/source\/<\/a>.<\/p>\n<p>Unpack it into the directory you want the source code kept, I choose <code>D:\\dev\\qt-src<\/code>. Create also the destination directory where you want your build to be, I chose <code>D:\\dev\\qt-build<\/code>. The directories can be anything and they can be in different drives, but I recommend avoiding to use directory names with spaces, as this may cause problems.<\/p>\n<p>You will also need to have Perl installed to run the configure script of Qt. If you don&#8217;t already have it, I recommend using the portable version of Strawberry Perl for Windows. You can download it <a href=\"http:\/\/strawberryperl.com\/releases.html\">here<\/a>. As this is a one-off step and you won&#8217;t need to do this next time you want to build Qt, unpack it into a suitable location in your system. I chose <code>D:\\dev\\perl<\/code>. Notice the batch file <code>portableshell.bat<\/code>, as we will need this in a bit.<\/p>\n<div id=\"attachment_68\" style=\"width: 523px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68\" loading=\"lazy\" class=\"size-full wp-image-68\" title=\"strawberry-perl\" src=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png\" alt=\"Strawberry Perl for Windows\" width=\"513\" height=\"340\" srcset=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png 513w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl-300x198.png 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><p id=\"caption-attachment-68\" class=\"wp-caption-text\">Directory of Strawberry Perl for Windows<\/p><\/div>\n<hr\/>\n<h3>Configuring and Compiling Qt<\/h3>\n<p>Now, open the Visual Studio Command Prompt, as shown here:<\/p>\n<div id=\"attachment_61\" style=\"width: 586px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-61\" loading=\"lazy\" class=\"size-full wp-image-61\" title=\"vs2010-command-prompt\" src=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/vs2010-command-prompt.png\" alt=\"Visual Studio Command Prompt\" width=\"576\" height=\"188\" srcset=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/vs2010-command-prompt.png 576w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/vs2010-command-prompt-300x97.png 300w\" sizes=\"(max-width: 576px) 100vw, 576px\" \/><p id=\"caption-attachment-61\" class=\"wp-caption-text\">Visual Studio Command Prompt<\/p><\/div>\n<p>You have to open the VS Command Prompt instead of a normal Command Prompt (cmd.exe), as this will load the Visual Studio variables into your environment, e.g. location of the Visual C++ compiler, linker etc. You also have to setup your environment with Perl support, so execute from within the VS Command Prompt the portableshell.bat. You can easily do this:<\/p>\n<pre>D:\\dev\\perl\\portableshell.bat<\/pre>\n<p>Now that your environment is setup with both VS and Perl support, change into the directory you intend to build and run the configure script in the source directory:<\/p>\n<pre>\r\ncd D:\\dev\\<font color=\"red\">qt-build<\/font>\r\nD:\\dev\\<font color=\"blue\">qt-src<\/font>\\configure -ltcg -opensource -mp\r\n<\/pre>\n<p>You may want to have other switches for your Qt, so investigate the options with <code>configure -help<\/code>, but these will work just fine if you don&#8217;t have any special needs. Briefly:<\/p>\n<ul>\n<li> <code>-ltcg<\/code> enables Link-time Code Generation, which tells the linker to call the compiler and perform whole program optimization.<\/li>\n<li> <code>-opensource <\/code> tells Qt you&#8217;re building for Open Source development, not commercial.<\/li>\n<li> <code>-mp <\/code> enables building Qt with multiple processes, which will speed up your build. Use this if you have a computer with multiple cores or cpus.<\/li>\n<\/ul>\n<p>The configure script will run for a while to compile some basic tools required and configure the Qt build for your system. Once configuration is finished you are ready to compile Qt. This may take a couple of hours and around 15-20GB of free space may be required to build everything in <code>D:\\dev\\qt-build<\/code>. To compile the code use either the default <code>nmake<\/code> or <code><a href=\"http:\/\/qt-project.org\/wiki\/jom\" target=\"_blank\">jom<\/a><\/code>. jom has the advantage of utilizing all cpus and cores on multicore machines and therefore it will build qt much faster than nmake. <\/p>\n<p>So, while still in <code>D:\\dev\\qt-build<\/code>, to start the compilation:<\/p>\n<pre>nmake -f D:\\dev\\qt-src\\Makefile<\/pre>\n<p>or<\/p>\n<pre>jom -f D:\\dev\\qt-src\\Makefile<\/pre>\n<p>Once the compilation is finished you may also want to build the documentation for Qt Assistant, which isn&#8217;t built by default, you can do this with:<\/p>\n<pre>nmake -f D:\\dev\\qt-src\\Makefile docs<\/pre>\n<pre>jom -f D:\\dev\\qt-src\\Makefile docs<\/pre>\n<p>If everything goes according to plan Qt will be built in <code>D:\\dev\\qt-build<\/code> and may occupy some 15-17GB of hard disk space. If you don&#8217;t want to rebuild Qt, you can clean up the build from intermediate files:<\/p>\n<pre>nmake -f D:\\dev\\qt-src\\Makefile clean<\/pre>\n<pre>jom -f D:\\dev\\qt-src\\Makefile clean<\/pre>\n<p>Keep in mind that <u>you cannot delete or move<\/u> the sources from <code>D:\\dev\\qt-src<\/code> as the shadow build files in D:\\dev\\qt-build reference headers in this directory and will not work when you try to compile software against it. If you really need to move your Qt build elsewhere then take a look at <a href=\"http:\/\/www.runfastsoft.com\/\" target=\"_blank\">QtMove<\/a>.<\/p>\n<hr\/>\n<h3>Software used<\/h3>\n<p> (versions here are updated each time I update the toolset and libraries)<\/p>\n<ul>\n<li>Microsoft Visual Studio 2010 Ultimate Edition\n<li><a href=\"http:\/\/get.qt.nokia.com\/qt\/source\/\">Nokia Qt<\/a> [v4.7.2, v4.8.0, v4.8.1]\n<li><a href=\"http:\/\/strawberryperl.com\/releases.html\">Strawberry Perl for Windows (Portable)<\/a> [v5.12.1, v5.16.0]\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A &#8220;shadow build&#8221; is an out-of-source build, where the source code is kept in one place and the build tree in another. I use this method to compile Qt on windows with Visual Studio (as of writing this post with VS2010). Preparation First download the latest Qt source code package. I usually download the latest [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[9,8],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stathis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\",\"name\":\"sigmoid\",\"description\":\"..oo..oo..oo..oo..oo..oo..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png\",\"contentUrl\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#webpage\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/\",\"name\":\"Qt Shadow build with Visual Studio - sigmoid\",\"isPartOf\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#primaryimage\"},\"datePublished\":\"2011-03-06T15:13:45+00:00\",\"dateModified\":\"2012-05-25T23:25:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Qt Shadow build with Visual Studio\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\",\"name\":\"stathis\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"caption\":\"stathis\"},\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/","twitter_misc":{"Written by":"stathis","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/","name":"sigmoid","description":"..oo..oo..oo..oo..oo..oo..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png","contentUrl":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2011\/03\/strawberry-perl.png"},{"@type":"WebPage","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#webpage","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/","name":"Qt Shadow build with Visual Studio - sigmoid","isPartOf":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#primaryimage"},"datePublished":"2011-03-06T15:13:45+00:00","dateModified":"2012-05-25T23:25:05+00:00","author":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41"},"breadcrumb":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2011\/03\/06\/qt-shadow-build-with-visual-studio\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.npcglib.org\/~stathis\/blog\/"},{"@type":"ListItem","position":2,"name":"Qt Shadow build with Visual Studio"}]},{"@type":"Person","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41","name":"stathis","image":{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo","inLanguage":"en-US","url":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","caption":"stathis"},"url":"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/"}]}},"_links":{"self":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":56,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":918,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/918"}],"wp:attachment":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}