{"id":135,"date":"2014-02-04T17:39:31","date_gmt":"2014-02-04T17:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=135"},"modified":"2015-09-30T11:22:26","modified_gmt":"2015-09-30T18:22:26","slug":"beaglebone-crosscompiler","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/beaglebone\/crosscompiler\/","title":{"rendered":"Tutorial: Cross-compiling C++ projects for Beaglebone"},"content":{"rendered":"<p>In this tutorial we will show how to use a cross-toolchain to quickly build and debug Beaglebone projects from Visual Studio using <a href=\"\/download\/\">VisualGDB 4.1<\/a> or later. Before you begin with the cross-compiler it is recommended to follow <a href=\"http:\/\/visualgdb.com\/tutorials\/beaglebone\/crosscompiler\/..\/\">this tutorial<\/a> to create a basic project using direct compilation on Beaglebone.<\/p>\n<ol>\n<li>Start Visual Studio. Go to File-&gt;New-&gt;Project and select VisualGDB-&gt;Linux Project Wizard. Specify the name and directory for your project: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/01-newprj.png\" alt=\"01-newprj\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>On the first wizard page select &#8220;Application&#8221; and click &#8220;Next&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/02-app.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/02-app.png\" alt=\"02-app\" width=\"700\" height=\"628\" \/><\/a><\/li>\n<li>The second wizard page allows switching between <a href=\"http:\/\/visualgdb.com\/tutorials\/beaglebone\/crosscompiler\/..\/\">compiling your source code on the Beaglebone board<\/a> and using a cross-compiler hosted on Windows. Select &#8220;Build the project locally&#8221; and then pick &#8220;Beaglebone&#8221; from the cross-toolchain list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/03-toolchain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/03-toolchain.png\" alt=\"03-toolchain\" width=\"700\" height=\"628\" \/><\/a>Ensure that the toolchain you download matches the Beaglebone image you are using. You can find out the compatible images on the <a href=\"http:\/\/gnutoolchains.com\/beaglebone\/\">Beaglebone toolchain<\/a> page.<\/li>\n<li>If you don&#8217;t have the toolchain installed yet, VisualGDB will automatically download and install it for you:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/04-install.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/04-install.png\" alt=\"04-install\" width=\"576\" height=\"163\" \/><\/a><\/li>\n<li>Select your Beaglebone board in the &#8220;Deployment computer&#8221; field: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/05-toolchain-done.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/05-toolchain-done.png\" alt=\"05-toolchain-done\" width=\"700\" height=\"628\" \/><\/a><\/li>\n<li>If you have just downloaded the toolchain it is recommended to synchronize the sysroot. This will take a few minutes, but will ensure that both the toolchain and your device are using the same headers and libraries and that the binaries produced by the toolchain will be 100% compatible with your device. Click &#8220;Synchronize headers and libraries&#8221; and synchronize with default settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/06-sysroot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/06-sysroot.png\" alt=\"06-sysroot\" width=\"420\" height=\"360\" \/><\/a><\/li>\n<li>Once the synchronization is done, click &#8220;Finish&#8221; to have your project created. Build it with Ctrl-Shift-B. Note that the building with a cross-toolchain is much faster then building it on Beaglebone:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/07-build.png\" alt=\"07-build\" width=\"698\" height=\"614\" \/><\/a><\/li>\n<li>Put a breakpoint in main() and start debugging by pressing F5. Once the breakpoint is hit you can use the common debugging techniques (e.g. stepping or viewing memory) to debug your program:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/08-break.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/08-break.png\" alt=\"08-break\" width=\"698\" height=\"614\" \/><\/a><\/li>\n<li>When done debugging, right-click on the project in Solution Explorer and select &#8220;VisualGDB Project Properties&#8221;. The VisualGDB Project Properties window allows changing various settings related to building and debugging (e.g. specifying additional libraries or resynchronizing the sysroot):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/09-properties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/crosscompiler\/09-properties.png\" alt=\"09-properties\" width=\"697\" height=\"723\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will show how to use a cross-toolchain to quickly build and debug Beaglebone projects from Visual<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[34,72,33],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/135"}],"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=135"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"predecessor-version":[{"id":1109,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/135\/revisions\/1109"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}