Setting up Codeblocks for linux(Ubuntu)

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

Setting up Codeblocks for linux(Ubuntu)

Post by kagi3624 »

Hello,

I have two wxWidget builds on my Ubuntu machine (GTK3 and one for cross compiling for windows). Both work fine which I can test by compiling the examples. How can I set up codeblocks so at least I can have a project that compiles for linux? There is no 'include' directory in my build like you need for setting up codeblocks in the windows tutorial.
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Setting up Codeblocks for linux(Ubuntu)

Post by New Pagodi »

kagi3624 wrote: Tue Sep 28, 2021 8:31 amHow can I set up codeblocks so at least I can have a project that compiles for linux?
The easiest way is to just use the new project wizard.
  1. From the menu, select File->New->Project...
    newproj.png
    newproj.png (34.78 KiB) Viewed 3728 times
  2. In the dialog that pops up, select wxWidgets project and then hit the "Go" button
    wxproj.png
    wxproj.png (56.68 KiB) Viewed 3728 times
  3. In the resulting wizard:
    • 1st screen (welcome) - just hit next
    • 2nd screen (wxWidgets version selection) - just hit next (doesn't matter on linux since wxconfig will be used).
    • 3rd screen (project title) enter a project title and folder to store the project in.
      wiz.png
      wiz.png (50.26 KiB) Viewed 3728 times
    • 4th screen (author and info) - enter info info if you want or leave blank.
    • 5th screen (gui builder and application type) - for now select either none or wxSmith for builder and frame based for type.
    • 6th scren (compiler and configuration) - just hit next
    • 7th screen (advanced options) - just hit finish
That will create a wxWidgets project that's ready to compile and run. (Assuming that you have a wxWidgets package installed on the system).

Incidentally, for the gui builder on the 5th screen, I'm a huge fan of wxFormbuilder, but in the past it's been somewhat difficult to install it on linux. However they just released 3.1.0 which includes a flatpak that seems to work Ok.
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

Re: Setting up Codeblocks for linux(Ubuntu)

Post by kagi3624 »

Hello New Pagodi,

it is actually pretty easy to install wxFormBuilder with the deb package but I run into the following problem while using it:
When I set up my wxProject (wxWidgets 3.1, Form Based, GCC) and open the fbp file, the formbuilder says that it removed properties, then after generating the code I cannot build in codeblocks anymore because some message box is not declared anymore (compiles just fine before I open the wxFormBuilder). Do I do something wrong here? I also get the same outcome if I chose Dialogue Based instead.

Edit: I compared the Frame files and in the beginning it says:
C++ code generated with wxFormBuilder (version Feb 17 2007)
while after code generation with wxFormBuilder it says
C++ code generated with wxFormBuilder (version 3.10.0-4761b0c)
How can I tell codeblocks to use the newer version for generating the project?
Attachments
wx1.JPG
wx1.JPG (19.91 KiB) Viewed 3670 times
wx2.JPG
wx2.JPG (17.3 KiB) Viewed 3670 times
wxerror.JPG
wxerror.JPG (68.8 KiB) Viewed 3670 times
Last edited by kagi3624 on Thu Sep 30, 2021 7:32 am, edited 1 time in total.
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Setting up Codeblocks for linux(Ubuntu)

Post by New Pagodi »

I don't know how to use clang. Sorry.

To get rid of the complaint about the message box, either just comment out that line or add "#include <wx/msgdlg.h> " to the top of the file. I guess the older version of wxFormbuilder that the codeblocks template is based on would generate files with that include, but not the newer versions don't.
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

Re: Setting up Codeblocks for linux(Ubuntu)

Post by kagi3624 »

Hello, I found the problem. The code::blocks generated project has 3 code files (GUIFrame.cpp, myprApp.cpp, myprMain.cpp) and 3 corresponding header files. In the myprMain.cpp there is a function

Code: Select all

void myprj21Frame::OnAbout(wxCommandEvent &event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}
which needs

Code: Select all

#include <wx/msgdlg.h>
but the updated GUIFrame.h does not include it. In replaces in the GUIFrame.h

Code: Select all

#ifdef WX_GCH
#include <wx_pch.h>
#else
#include <wx/wx.h>
#endif

#include <wx/menu.h>
with

Code: Select all

#pragma once

#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/menu.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
Sure, I can add the missing header to the main.h and it compiles fine now. But I have still a question now, since code::blocks use sooo outdated files maybe the way the project is set up is outdated too? Is there a tutorial anywhere on how to set up the App.cpp and the main.cpp for 3.1? Thank you!!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Setting up Codeblocks for linux(Ubuntu)

Post by ONEEYEMAN »

Hi,
What version of C::B do you use?
And I presume you installed it from the repoisitory?

Thank you.
kagi3624
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Feb 26, 2020 8:13 am

Re: Setting up Codeblocks for linux(Ubuntu)

Post by kagi3624 »

That's right. It is 20.03 and it is showing gcc and wxWidget version wrong. I have gcc 11 and

Code: Select all

wx-config --list
is showing

Code: Select all

Default config is gtk3-unicode-static-3.1
Attachments
cd.jpg
cd.jpg (39.93 KiB) Viewed 3590 times
Post Reply