{"id":4453,"date":"2023-09-15T08:22:05","date_gmt":"2023-09-15T08:22:05","guid":{"rendered":"https:\/\/truelogic.org\/wordpress\/?p=4453"},"modified":"2024-10-09T15:35:50","modified_gmt":"2024-10-09T15:35:50","slug":"setting-up-wxwidgets-with-codeblocks-in-ubuntu","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2023\/09\/15\/setting-up-wxwidgets-with-codeblocks-in-ubuntu\/","title":{"rendered":"Setting up wxWidgets with Code:Blocks in Ubuntu"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>In continuation to the other posts about how to setup wxWidgets under various platforms , we look at using wxWidgets with Code:Blocks under Ubuntu.  The advantage of Code:Blocks is that it has an existing integration with wxSmith which is  a GUI builder for wxWidgets and its very easy to integrate the wxWidgets library into the IDE.<\/p>\n\n\n\n<p><strong>PRE-REQUISITES<\/strong><\/p>\n\n\n\n<p>Before installing Code::Blocks, it is assumed that wxWidgets is already downloaded and built. If not then you can follow the instructions in<a href=\" https:\/\/truelogic.org\/wordpress\/2021\/10\/31\/setting-up-wxwidgets-environment-for-c-in-ubuntu-linux\/\"> https:\/\/truelogic.org\/wordpress\/2021\/10\/31\/setting-up-wxwidgets-environment-for-c-in-ubuntu-linux\/<\/a><\/p>\n\n\n\n<p><strong>INSTALLING CODE::BLOCKS<\/strong><\/p>\n\n\n\n<p>We need to add a repository  from which to download Code::Blocks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo add-apt-repository universe\nsudo apt update\nsudo apt install codeblocks\n<\/code><\/pre>\n\n\n\n<p>This will complete the installation of Code::Blocks. However we also need to install some extra plugins to make development easier:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install codeblocks-contrib<\/code><\/pre>\n\n\n\n<p><strong>CODE::BLOCKS FIRST RUN<\/strong><\/p>\n\n\n\n<p>When you run CB for the first time, it will detect the installed C\/C++ compilers in the system and prompt you to select which one to select as default. Most likely it will be gcc. Once the IDE has opened, you have to setup some global compiler and linker flags. For that you need a project. Go to File-&gt;New Project. Give it any name. Then in the project create a new file called test.cpp and put in some very basic wxWidgets code. Before you can build it, you have to update the config settings. <\/p>\n\n\n\n<p>In the menubar go to Project-&gt;Build Options<\/p>\n\n\n\n<p>Under the Compiler Flags section, right click on the list and choose New Flag. Give the name as &#8220;wxWidgets Compiler Settings&#8221;. In Compiler flags field put `<code>wx-config --cxxflags<\/code>`<\/p>\n\n\n\n<p>Do not omit the leading and trailing backticks. Click Ok<\/p>\n\n\n\n<p>Again under the Compiler Flags section, right click on the list and choose New Flag. Give the name as &#8220;wxWidgets Linker Settings&#8221;. In Linker flags field put `<code>wx-config --libs<\/code>` . Click Ok<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"557\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-41-55.png\" alt=\"\" class=\"wp-image-4457\" style=\"width:840px;height:557px\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-41-55.png 675w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-41-55-620x512.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-41-55-300x248.png 300w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"345\" height=\"431\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-42-28.png\" alt=\"\" class=\"wp-image-4458\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-42-28.png 345w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-42-28-300x375.png 300w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/figure>\n\n\n\n<p>If you are planning to use webview component, then you have to add webview to the Linker Flag: `<code>wx-config --libs<\/code> webview` and in Search Directories->Linker tab, add the libs folder of wxWidgets. Without the libs folder, it will not find the library for webview.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"739\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2024-10-09-21-02-58.png\" alt=\"\" class=\"wp-image-4593\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2024-10-09-21-02-58.png 738w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2024-10-09-21-02-58-620x621.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2024-10-09-21-02-58-300x300.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/figure>\n\n\n\n<p>Now we are ready to build and run wxWidgets programs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"530\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-940x530.png\" alt=\"\" class=\"wp-image-4460\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-940x530.png 940w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-620x350.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-300x169.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-768x433.png 768w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10-678x381.png 678w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2023\/09\/Screenshot-from-2023-09-15-13-44-10.png 1264w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW In continuation to the other posts about how to setup wxWidgets under various platforms , we look at using wxWidgets with Code:Blocks under Ubuntu. <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2023\/09\/15\/setting-up-wxwidgets-with-codeblocks-in-ubuntu\/\" title=\"Setting up wxWidgets with Code:Blocks in Ubuntu\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":4405,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,365],"tags":[],"class_list":["post-4453","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cc","category-wxwidgets"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=4453"}],"version-history":[{"count":11,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4453\/revisions"}],"predecessor-version":[{"id":4594,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4453\/revisions\/4594"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/4405"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=4453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=4453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=4453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}