{"id":667,"date":"2023-11-20T21:27:23","date_gmt":"2023-11-20T10:27:23","guid":{"rendered":"https:\/\/www.samontab.com\/web\/?p=667"},"modified":"2023-11-20T21:27:25","modified_gmt":"2023-11-20T10:27:25","slug":"using-qt-creator-as-your-ide-for-rust","status":"publish","type":"post","link":"https:\/\/www.samontab.com\/web\/2023\/11\/using-qt-creator-as-your-ide-for-rust\/","title":{"rendered":"Using Qt Creator as your IDE for Rust"},"content":{"rendered":"\n<p>Qt Creator is a great IDE for C++, and it recently included support for the <a href=\"https:\/\/microsoft.github.io\/language-server-protocol\/\">Language Server Protocol<\/a>. This means that we can add the ability to write in other languages to the IDE, like Rust for example. In this post I will show you how to do exactly that.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e2e3e4\" data-has-transparency=\"false\" style=\"--dominant-color: #e2e3e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-1024x535.png\" alt=\"\" class=\"wp-image-683 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-1024x535.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-300x157.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-768x401.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-1536x803.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1-2048x1070.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e6e7e8\" data-has-transparency=\"false\" style=\"--dominant-color: #e6e7e8;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-1024x555.png\" alt=\"\" class=\"wp-image-685 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-1024x555.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-300x163.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-768x416.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-1536x833.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1-2048x1111.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>First, make sure you have <a href=\"https:\/\/www.rust-lang.org\/tools\/install\">Rust installed<\/a> and that everything works as you would expect. For example, you should be able to create a new Rust project with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cargo new ide_rust<\/code><\/pre>\n\n\n\n<p>We can open these Rust files into Qt Creator in the following way. Go to <strong>File->New File or Project<\/strong>, then select <strong>Import Project<\/strong>, and <strong>Import Existing Project<\/strong>, as shown in the following image:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"eff2f3\" data-has-transparency=\"false\" style=\"--dominant-color: #eff2f3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"641\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2-1024x641.png\" alt=\"\" class=\"wp-image-669 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2-1024x641.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2-300x188.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2-768x481.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2-1536x962.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_2.png 1749w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now simply select the folder that was created by cargo and set any Project name you want:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"eceeef\" data-has-transparency=\"false\" style=\"--dominant-color: #eceeef;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"481\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3-1024x481.png\" alt=\"\" class=\"wp-image-670 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3-1024x481.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3-300x141.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3-768x361.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3-1536x722.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_3.png 1626w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Under file selection, simply click on the folder to add all the files:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"f2f2f3\" data-has-transparency=\"false\" style=\"--dominant-color: #f2f2f3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"582\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4-1024x582.png\" alt=\"\" class=\"wp-image-671 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4-1024x582.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4-300x171.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4-768x437.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4-1536x873.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_4.png 1613w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Finally choose if you want to use git or other version control software and click on <strong>Finish<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"ebeced\" data-has-transparency=\"false\" style=\"--dominant-color: #ebeced;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"583\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5-1024x583.png\" alt=\"\" class=\"wp-image-672 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5-1024x583.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5-300x171.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5-768x437.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5-1536x874.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_5.png 1626w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You should now be able to navigate and open the files of your project in the IDE:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e0e2e2\" data-has-transparency=\"false\" style=\"--dominant-color: #e0e2e2;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"464\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_6-1024x464.png\" alt=\"\" class=\"wp-image-673 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_6-1024x464.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_6-300x136.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_6-768x348.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_6.png 1473w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We are now going to configure Qt Creator to work with Rust. Go to <strong>Tools->Options->Kits<\/strong> and go to the <strong>Debuggers<\/strong> tab. Click on <strong>Add<\/strong>, specify a name like <strong>Rust-GDB<\/strong> for example, and under <strong>Path<\/strong> specify where <strong>rust-gdb<\/strong> is located in your machine:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"f3f3f4\" data-has-transparency=\"false\" style=\"--dominant-color: #f3f3f4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"698\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7-1024x698.png\" alt=\"\" class=\"wp-image-674 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7-1024x698.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7-300x204.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7-768x523.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7-1536x1047.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_7.png 1642w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now go to the <strong>Kits<\/strong> tab, click on <strong>Add<\/strong>. Select a name, like Rust for example, and on <strong>Debugger<\/strong> select <strong>Rust-GDB<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"f2f4f6\" data-has-transparency=\"false\" style=\"--dominant-color: #f2f4f6;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"850\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1-1024x850.png\" alt=\"\" class=\"wp-image-676 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1-1024x850.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1-300x249.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1-768x637.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1-1536x1275.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_8-1.png 1927w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now we are going to update the syntax highlighter. Click on <strong>Text Editor<\/strong> and go to <strong>Generic Highlighter<\/strong>. Then, click on <strong>Download Definitions<\/strong>, and then <strong>Reload Definitions<\/strong>. This should update them to the latest version.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"f2f3f3\" data-has-transparency=\"false\" style=\"--dominant-color: #f2f3f3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"533\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9-1024x533.png\" alt=\"\" class=\"wp-image-677 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9-1024x533.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9-300x156.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9-768x400.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9-1536x800.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_9.png 1926w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now click on OK to close the Options window and go to <strong>Projects<\/strong> (on the left side), and under both, the build and clean steps, simply remove them by clicking on the small <strong>x<\/strong> mark on their right side:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e2e2e3\" data-has-transparency=\"false\" style=\"--dominant-color: #e2e2e3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"604\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_10-1024x604.png\" alt=\"\" class=\"wp-image-678 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_10-1024x604.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_10-300x177.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_10-768x453.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_10.png 1485w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e3e3e4\" data-has-transparency=\"false\" style=\"--dominant-color: #e3e3e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"595\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_11-1024x595.png\" alt=\"\" class=\"wp-image-679 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_11-1024x595.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_11-300x174.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_11-768x446.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_11.png 1489w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now at the build and clean steps, click on <strong>Add Build Step<\/strong>, select <strong>Custom Process Step<\/strong> and write cargo build and cargo clean respectively at the appropriate fields:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e6e6e7\" data-has-transparency=\"false\" style=\"--dominant-color: #e6e6e7;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"890\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_12-1024x890.png\" alt=\"\" class=\"wp-image-680 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_12-1024x890.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_12-300x261.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_12-768x667.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_12.png 1463w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now click on the <strong>Run<\/strong> tab on the left and select your executable:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e5e6e6\" data-has-transparency=\"false\" style=\"--dominant-color: #e5e6e6;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"493\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13-1024x493.png\" alt=\"\" class=\"wp-image-681 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13-1024x493.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13-300x144.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13-768x370.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13-1536x739.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_13.png 1814w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can now go back to the <strong>Edit<\/strong> tab and edit the file. You can press <strong>CTRL-B<\/strong> to build or <strong>CTRL-R<\/strong> to run your application, as well as auto-complete with <strong>CTRL-Space<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e2e3e4\" data-has-transparency=\"false\" style=\"--dominant-color: #e2e3e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1024x535.png\" alt=\"\" class=\"wp-image-682 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1024x535.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-300x157.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-768x401.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-1536x803.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_14-2048x1070.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can also press <strong>F5<\/strong> to start debugging the application:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-dominant-color=\"e6e7e8\" data-has-transparency=\"false\" style=\"--dominant-color: #e6e7e8;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1024x555.png\" alt=\"\" class=\"wp-image-684 not-transparent\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1024x555.png 1024w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-300x163.png 300w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-768x416.png 768w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-1536x833.png 1536w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2023\/11\/qt_15-2048x1111.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And that&#8217;s it, you can now write, build, run, and debug applications using Rust in Qt Creator.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Qt Creator is a great IDE for C++, and it recently included support for the Language Server Protocol. This means that we can add the ability to write in other languages to the IDE, like Rust for example. In this post I will show you how to do exactly that. First, make sure you have [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[32,96],"class_list":["post-667","post","type-post","status-publish","format-standard","hentry","category-programming","tag-c","tag-rust"],"_links":{"self":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/comments?post=667"}],"version-history":[{"count":0,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}