{"id":2106,"date":"2016-10-27T14:00:11","date_gmt":"2016-10-27T21:00:11","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=2106"},"modified":"2016-10-27T14:00:11","modified_gmt":"2016-10-27T21:00:11","slug":"using-automatic-include-path-discovery-for-imported-projects","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/intellisense\/headers\/","title":{"rendered":"Using Automatic Include Path Discovery for Imported Projects"},"content":{"rendered":"<p>This tutorial shows how to use the VisualGDB include path discovery feature to automatically set missing include paths for imported projects. We will import a basic project that has the following structure:<\/p>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/tree.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2107\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/tree.png\" alt=\"tree\" width=\"536\" height=\"178\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/tree.png 536w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/tree-300x100.png 300w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a>The source.cpp file has the following contents:<\/p>\n<pre class=\"\">#include &lt;sub.h&gt;\r\n#include &lt;stdio.h&gt;\r\n\/\/#include &lt;add.h&gt;\r\n\r\nint main()\r\n{\r\n\u00a0\u00a0 \u00a0printf(\"result = %d\\n\", subtract(10, 3));\r\n\u00a0\u00a0 \u00a0return 0;\r\n}<\/pre>\n<p>It expects the project to be compiled with the following include directories:<\/p>\n<ul>\n<li>&lt;project directory&gt;\\subdir<\/li>\n<li>&lt;project directory&gt;\\..\\library<\/li>\n<\/ul>\n<p>Before you begin, install VisualGDB 5.2 or later.<\/p>\n<ol>\n<li>Open Visual Studio and launch any of the VisualGDB Project wizards. We will use the Linux project wizard with the Raspberry Pi toolchain, but the same steps will work with any other VisualGDB project as long as it is using the Clang IntelliSense.\u00a0<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-prjname3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2111\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-prjname3.png\" alt=\"01-prjname\" width=\"861\" height=\"582\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-prjname3.png 861w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-prjname3-300x203.png 300w\" sizes=\"(max-width: 861px) 100vw, 861px\" \/><\/a><\/li>\n<li>Select &#8220;Create a new project -&gt; Application -&gt; MSBuild&#8221;. We will not use the &#8220;Import project&#8221; functionality as it would expect us to have an existing Makefile that can build the project.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2112\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-newprj.png\" alt=\"02-newprj\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-newprj.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-newprj-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Select your toolchain and the target machine:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-cross.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2113\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-cross.png\" alt=\"03-cross\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-cross.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-cross-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create the project. Then delete the main source file, right-click in Solution Explorer and select &#8220;Add-&gt;Import folder recursively&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2114\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-import.png\" alt=\"04-import\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-import.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-import-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>Enter the path to the &#8220;project&#8221; folder and click &#8220;OK&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/prj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2115\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/prj.png\" alt=\"prj\" width=\"542\" height=\"439\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/prj.png 542w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/prj-300x243.png 300w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/a><\/li>\n<li>If you try to build the project now, Visual Studio will complain that the <strong>sub.h<\/strong> file is missing. This happens because the &#8220;subdir&#8221; directory containing it was never specified as an include search directory:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-missing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2116\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-missing.png\" alt=\"05-missing\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-missing.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-missing-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>Double-click on the error message. VisualGDB will automatically locate the missing header file and display a hint about it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-suggest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2117\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-suggest.png\" alt=\"06-suggest\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-suggest.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-suggest-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a>Note how IntelliSense starts locating the header file immediately, but the build would still fail.<\/li>\n<li>To fix the build settings automatically, click the &#8220;Add to Project Properties&#8221; button and then press &#8220;Add now&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-addnow.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2118\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-addnow.png\" alt=\"07-addnow\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-addnow.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-addnow-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>This will automatically update the project properties for the current configuration and the project will now build successfully:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-builddone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2119\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-builddone.png\" alt=\"08-builddone\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-builddone.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-builddone-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>Uncomment the <strong>#include &lt;add.h&gt;<\/strong> line. As <strong>add.h<\/strong> is located outside the imported project directory, VisualGDB won&#8217;t automatically find it and will display it as missing:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-locate.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2121\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-locate.png\" alt=\"10-locate\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-locate.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-locate-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>The easiest way to help VisualGDB locate it is to press &#8220;Locate&#8221; and point to the file on your disk:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/11-addh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2123\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/11-addh.png\" alt=\"11-addh\" width=\"862\" height=\"365\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/11-addh.png 862w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/11-addh-300x127.png 300w\" sizes=\"(max-width: 862px) 100vw, 862px\" \/><\/a>If the same directory contains other missing files, VisualGDB will automatically locate those. If you have many files from different directories missing, you can click &#8220;Search in another location&#8221; and specify the top folder where VisualGDB should search for them.<\/li>\n<li>Once the file has been located, IntelliSense will begin recognizing it immediately and VisualGDB will give you a chance to review the discovered directories:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/12-confirm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2124\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/12-confirm.png\" alt=\"12-confirm\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/12-confirm.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/12-confirm-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<li>Click &#8220;Add to Project Properties&#8221; -&gt; &#8220;Add Now&#8221; to add the new directory to the build properties and fix the build:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/13-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2125\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/13-build.png\" alt=\"13-build\" width=\"1019\" height=\"644\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/13-build.png 1019w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/13-build-300x190.png 300w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/a><\/li>\n<\/ol>\n<p>The automatic updating of build settings will work for MSBuild, Make, CMake and QMake projects created by VisualGDB. For imported projects with custom Makefiles VisualGDB can still update IntelliSense, but won&#8217;t be able to automatically edit the build system files.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use the VisualGDB include path discovery feature to automatically set missing include paths for imported<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[134],"tags":[52],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2106"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=2106"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2106\/revisions"}],"predecessor-version":[{"id":2127,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2106\/revisions\/2127"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=2106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=2106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=2106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}