{"id":2078,"date":"2016-10-25T12:00:43","date_gmt":"2016-10-25T19:00:43","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=2078"},"modified":"2016-10-25T12:00:43","modified_gmt":"2016-10-25T19:00:43","slug":"using-windows-10-linux-subsystem-to-develop-linux-applications","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/linux\/win10\/","title":{"rendered":"Using Windows 10 Linux Subsystem to develop Linux applications"},"content":{"rendered":"<p>This tutorial shows how to use the new Windows 10 Linux subsystem (lxss) to develop Linux applications from Visual Studio. The Linux subsystem allows running native Linux applications side-by-side with the Windows processes without installing a separate virtual machine. This improves performance and allows quickly testing out your Linux code without installing a separate operating system.<\/p>\n<p>Before you begin, install VisualGDB 5.2 or later.<\/p>\n<ol>\n<li>Ensure that you are using 64-bit Windows 10 version 1607 or later:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/00-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2079\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/00-build.png\" alt=\"00-build\" width=\"460\" height=\"406\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/00-build.png 460w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/00-build-300x265.png 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/a><\/li>\n<li>Enable the Developer mode via system settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-devmode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2080\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-devmode.png\" alt=\"01-devmode\" width=\"1202\" height=\"933\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-devmode.png 1202w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-devmode-300x233.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/01-devmode-1024x795.png 1024w\" sizes=\"(max-width: 1202px) 100vw, 1202px\" \/><\/a><\/li>\n<li>Open the &#8220;Add\/Remove programs&#8221;, click &#8220;Turn windows features on or off&#8221; and enable the Windows Subsystem for Linux:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-lxss.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2081\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-lxss.png\" alt=\"02-lxss\" width=\"415\" height=\"368\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-lxss.png 415w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/02-lxss-300x266.png 300w\" sizes=\"(max-width: 415px) 100vw, 415px\" \/><\/a><\/li>\n<li>Once the subsystem is installed, open the bash shell from the Start menu and ensure that gcc is installed. If not, you can install it by running &#8220;sudo apt-get install gcc&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-gcc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2082\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-gcc.png\" alt=\"03-gcc\" width=\"979\" height=\"448\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-gcc.png 979w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/03-gcc-300x137.png 300w\" sizes=\"(max-width: 979px) 100vw, 979px\" \/><\/a><\/li>\n<li>Start Visual Studio and select File-&gt;New Project-&gt;VisualGDB-&gt;Linux Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2083\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-prjname.png\" alt=\"04-prjname\" width=\"869\" height=\"633\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-prjname.png 869w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/04-prjname-300x219.png 300w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><\/a><\/li>\n<li>In this tutorial we will show how to create a basic new project with MSBuild. VisualGDB also supports creating projects with other build systems, importing existing projects and creating unit test projects:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-newproj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2084\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-newproj.png\" alt=\"05-newproj\" width=\"816\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-newproj.png 816w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/05-newproj-300x243.png 300w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/a><\/li>\n<li>On the Computer Selection page select &#8220;Use the Windows 10 Linux Subsystem&#8221; and proceed with the default toolchain:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-subsys.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2085\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-subsys.png\" alt=\"06-subsys\" width=\"816\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-subsys.png 816w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/06-subsys-300x243.png 300w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/a><\/li>\n<li>When you press &#8216;Finish&#8217;, VisualGDB will check that the Linux Subsystem on your machine is usable and contains all necessary tools:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2086\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-test.png\" alt=\"07-test\" width=\"470\" height=\"364\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-test.png 470w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/07-test-300x232.png 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/a><\/li>\n<li>When the project is created, build it via Build-&gt;Build Solution:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2087\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-build.png\" alt=\"08-build\" width=\"1280\" height=\"760\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-build.png 1280w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-build-300x178.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/08-build-1024x608.png 1024w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/a>VisualGDB will automatically convert the Windows project path to the <strong>\/mnt\/&lt;drive&gt;\/path<\/strong> form used by the Linux subsystem and will automatically configure IntelliSense to look into Linux include directories under <strong>%LOCALAPPDATA%\\lxss\\rootfs<\/strong>.<\/li>\n<li>Set a breakpoint in main() and hit F5 to begin debugging. VisualGDB will display a warning that it could not set controlling terminal. This is normal and can be safely ignored:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/09-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2088\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/09-debug.png\" alt=\"09-debug\" width=\"1281\" height=\"760\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/09-debug.png 1281w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/09-debug-300x178.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/09-debug-1024x608.png 1024w\" sizes=\"(max-width: 1281px) 100vw, 1281px\" \/><\/a><\/li>\n<li>You can use the VisualGDB Project Properties window to edit various project properties, add references to test frameworks or check advanced IntelliSense settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2089\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-settings.png\" alt=\"10-settings\" width=\"1098\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-settings.png 1098w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-settings-300x202.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/10\/10-settings-1024x690.png 1024w\" sizes=\"(max-width: 1098px) 100vw, 1098px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use the new Windows 10 Linux subsystem (lxss) to develop Linux applications from Visual Studio.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[33],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2078"}],"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=2078"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2078\/revisions"}],"predecessor-version":[{"id":2090,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2078\/revisions\/2090"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=2078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=2078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=2078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}