{"id":146,"date":"2014-02-04T17:39:31","date_gmt":"2014-02-04T17:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=146"},"modified":"2015-07-19T09:01:35","modified_gmt":"2015-07-19T16:01:35","slug":"linux-clang","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/linux\/clang\/","title":{"rendered":"Creating llvm\/clang Linux projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to create, build and debug a Linux application using the clang compiler under Visual Studio with VisualGDB.<\/p>\n<ol>\n<li>Install <a href=\"\/download\/\">VisualGDB<\/a> on your Windows machine with Visual Studio. Start Visual Studio, select File-&gt;New Project-&gt;VisualGDB-&gt;Linux Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/01-newproj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/01-newproj.png\" alt=\"01-newproj\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>On the first wizard page select &#8220;New Application&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/02-application.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/02-application.png\" alt=\"02-application\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Select a computer where you want to run clang. If you have troubles setting up the SSH connection, follow the <a href=\"\/tutorials\/linux\/\">Linux quickstart manual<\/a>.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/02-compsel.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/02-compsel.png\" alt=\"02-compsel\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>If you don&#8217;t have clang installed, or are unsure about it, click at the terminal icon to the right from the computer selection. A new terminal window will open. Run the following command to install clang on your Debian-based Linux system:\n<pre>sudo apt-get install llvm clang<\/pre>\n<p>If you are using a Red Hat-based system instead, use <strong> yum<\/strong> to install LLVM\/clang.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/03-installclang.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/03-installclang.png\" alt=\"03-installclang\" width=\"696\" height=\"498\" \/><\/a><\/li>\n<li>The terminal window is running in a separate process, so you can safely go back to the wizard and keep it running in the background. Once you press the &#8220;Next&#8221; button in the wizard, VisualGDB will automatically test your toolchain:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/05-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/05-test.png\" alt=\"05-test\" width=\"484\" height=\"342\" \/><\/a><\/li>\n<li>The last wizard page allows customizing the way source files are transferred between the Windows and the Linux computers. The easiest way is to accept the default settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/06-filetransfer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/06-filetransfer.png\" alt=\"06-filetransfer\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>When you press Finish, VisualGDB will create a new Visual Studio project for you. Press Ctrl-Shift-B to build it. You will see how clang is invoked in the background:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/07-build.png\" alt=\"07-build\" width=\"700\" height=\"644\" \/><\/a><\/li>\n<li>Set a breakpoint anywhere in the code and press F5 to start debugging. When a breakpoint is hit, right-click anywhere in the source code and select &#8220;Go to disassembly&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/08-disasm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/08-disasm.png\" alt=\"08-disasm\" width=\"700\" height=\"644\" \/><\/a><\/li>\n<li>You can use the disassembly view to see the source code and the corresponding disassembler dump:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/09-options.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/09-options.png\" alt=\"09-options\" width=\"700\" height=\"644\" \/><\/a>Use the context menu to set various disassembly options and select which information to show.<\/li>\n<li>You can easily modify the compiler flags by editing the <strong>flags.mak<\/strong> file:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/10-flags.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/clang\/10-flags.png\" alt=\"10-flags\" width=\"700\" height=\"644\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create, build and debug a Linux application using the clang compiler under Visual Studio with<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[76,33],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/146"}],"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=146"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/146\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}