{"id":150,"date":"2014-02-04T17:39:31","date_gmt":"2014-02-04T17:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=150"},"modified":"2014-02-04T17:39:31","modified_gmt":"2014-02-04T17:39:31","slug":"linux-import","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/linux\/import\/","title":{"rendered":"Importing remote Linux projects to Visual Studio"},"content":{"rendered":"\n<p>This tutorial shows how to import a Linux project from a Linux machine to Visual Studio to build and debug it remotely. We will download the sources of <a href=\"http:\/\/www.gnu.org\/software\/mc\/\">Midnight Commander<\/a> to the Linux machine, import them to Visual Studio, build, debug and modify them directly from the Visual Studio. We will use the VisualGDB wizard to setup a network share and connect to it automatically.<\/p>\n<p>To proceed with the tutorial you will need a Windows machine and a Linux machine. You can use 2 physical computers, a Windows computer running Linux inside <a href=\"http:\/\/virtualbox.org\/\"> VirtualBox<\/a>\/<a href=\"http:\/\/vmware.com\/\">VMWare<\/a> or vice versa.<\/p>\n<ol>\n<li>Install <a href=\"\/download\">VisualGDB<\/a> on your Windows machine with Visual Studio.<\/li>\n<li>On your Linux machine get the source code of Midnight Commander by running the following commands from your home directory:\n<pre>sudo apt-get build-dep mc\r\napt-get source mc<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/01-getsource.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/01-getsource.png\" alt=\"01-getsource\" width=\"583\" height=\"566\" \/><\/a><\/li>\n<li>When the source code is downloaded, go to the newly created directory and configure Midnight Commander with default settings:\n<pre>cd mc-&lt;VERSION&gt;\r\n.\/configure<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/02-configure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/02-configure.png\" alt=\"02-configure\" width=\"583\" height=\"566\" \/><\/a><\/li>\n<li>Open Visual Studio on your Windows machine. Select File-&gt;New-&gt;Project and find VisualGDB project wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/03-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/03-newprj.png\" alt=\"03-newprj\" width=\"700\" height=\"441\" \/><\/a><\/li>\n<li>Enter a project name and specify the directory where it should be stored. Press OK.<\/li>\n<li>On the first page select &#8220;Import a project&#8221;: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/04-import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/04-import.png\" alt=\"04-import\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>If you have not used this computer with VisualGDB before, you will need to setup an SSH connection (see <a href=\"\/tutorials\/linux\/\">this tutorial <\/a>if you get stuck). Otherwise simply select the machine from the list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/05-buildmachine.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/05-buildmachine.png\" alt=\"05-buildmachine\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>When you press &#8220;Next&#8221;, VisualGDB will test your toolchain for inconsistencies. If missing packages are detected, you will see a detailed error message.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/06-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/06-test.png\" alt=\"06-test\" width=\"484\" height=\"342\" \/><\/a><\/li>\n<li>On this page you need to specify the location of your source files on the remote machine. Use the browse button to find it easily:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/07-sourcelocation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/07-sourcelocation.png\" alt=\"07-sourcelocation\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>This page allows selecting how Visual Studio will access the source files on the Linux machine. The recommended way would be to share a folder using samba. Click &#8220;Setup&#8221; to do it automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/08-sourceaccess.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/08-sourceaccess.png\" alt=\"08-sourceaccess\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Creating a separate shared folder for each project would be too much overhead, so we simply share a parent folder (the home folder in this case). You can pick any valid folder and any share name here. To prevent access from unauthorized users you can specify a username and a password that will be used to access the folder over SMB. VisualGDB will remember them and use them automatically to establish the connection. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/09-newshare.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/09-newshare.png\" alt=\"09-newshare\" width=\"520\" height=\"491\" \/><\/a><\/li>\n<li>When you press OK, you will most likely get an error message stating that you have no permission to modify the samba configuration. This is by design &#8211; only the <strong> root <\/strong>user can normally create shared folders on Linux. Press &#8220;yes&#8221; to reconnect as root and sharing the folder again:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/10-root.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/10-root.png\" alt=\"10-root\" width=\"489\" height=\"214\" \/><\/a><\/li>\n<li>Once the share is made, the VisualGDB wizard will display the information about it on the diagram below. Use it to verify that the setup matches your expectations.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/11-sharemade.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/11-sharemade.png\" alt=\"11-sharemade\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>On this final page you can specify the commands VisualGDB should use to build your project. You can also select the main executable right now, or choose to provide it later.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/12-buildcommands.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/12-buildcommands.png\" alt=\"12-buildcommands\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>If you are not sure about the build command and build directory, press the &#8220;Run build command now&#8221; button to test the command right now before saving your choices:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/13-testbuild.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/13-testbuild.png\" alt=\"13-testbuild\" width=\"700\" height=\"420\" \/><\/a><\/li>\n<li>Press Finish to create your project. Now you can build it with Ctrl+Shift+B and start debugging with F5. If you have not selected the main binary before, VisualGDB will kindly ask you to do it now:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/14-selectexe.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/14-selectexe.png\" alt=\"14-selectexe\" width=\"500\" height=\"180\" \/><\/a><\/li>\n<li>Use the &#8220;browse&#8221; button to find the binary easily. For the <strong>mc<\/strong> project it is located inside the src directory:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/15-selectmc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/15-selectmc.png\" alt=\"15-selectmc\" width=\"500\" height=\"300\" \/><\/a><\/li>\n<li>VisualGDB will launch your project and show the output in the Program console window. VisualGDB provides an XTerm-compatible terminal emulator, so you can use your keyboard an mouse as usual:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/16-mcscreen.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/16-mcscreen.png\" alt=\"16-mcscreen\" width=\"699\" height=\"622\" \/><\/a><\/li>\n<li>Click on the &#8220;break all&#8221; button to stop the execution and see the call stack:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/17-callstack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-17\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/import\/17-callstack.png\" alt=\"17-callstack\" width=\"699\" height=\"622\" \/><\/a><\/li>\n<li>You can now use all the usual Visual Studio debugging techniques: set breakpoints, examine call stack, watch windows, etc. When done, press Shift-F5 to stop debugging.<\/li>\n<\/ol>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to import a Linux project from a Linux machine to Visual Studio to build and debug<\/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":[41,33],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/150"}],"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=150"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}