How to build wxWidgets project with g++

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
hoangnguyen
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Aug 23, 2022 11:21 am

How to build wxWidgets project with g++

Post by hoangnguyen »

Hello everyone! I have a file main.cpp:

Code: Select all

#include <wx/wx.h>
 
class App : public wxApp {
public:
    bool OnInit() {
        wxFrame* window = new wxFrame(NULL, wxID_ANY, "GUI Test", wxDefaultPosition, wxSize(600, 400));
        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
        wxStaticText* text = new wxStaticText(window, wxID_ANY, "Well Done!\nEverything seems to be working",
                                              wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
        text->SetFont(wxFont(20, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
        sizer->Add(text, 1, wxALIGN_CENTER);
        window->SetSizer(sizer);
        window->Show();
        return true;
    }
};
 
wxIMPLEMENT_APP(App);
I'm try

Code: Select all

g++ -ID:\WxWidgets\include -LD:\WxWidgets\lib\vc_lib -o hello.exe main.cpp -s
but not ok

How to fix this?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to build wxWidgets project with g++

Post by PB »

For starters:
1. Read the wxWidgets documentation regarding which include folders to use (hint: it's 2).
2. Do not attempt to use MSVC-built libraries with GCC.
3. Do not forget to name libraries to link with: (a) wxWidgets libraries and (b) Windows libraries static wxWidgets build needs.

You will likely also need to add some defines and compiler/linker options (e.g., to suppress the console in a GUI application). IMO, using a by hand command line when compiling a non-trivial application is not a way to go and one should use a build system (via IDE, CMake..).
liowan
Knows some wx things
Knows some wx things
Posts: 34
Joined: Tue Feb 08, 2022 8:57 pm

Embarcadero Dev C++ Registration

Post by liowan »

I'm deeply sorry for this late response! However, if you would still like to try out Emb. Dev C++ IDE, I have some suggestions:

(1) Directly from Embarcadero. Yes you must register. Primarily Emb. provides their software to comercial software developers, hence the registration. For company put Private. For phone, make up a number - it doesn't matter, they're not going to call you. The number is only there in case you call in for tech support and they need to return your call. mostly they will send you offersand info via email.

(2) Optionally, you can obtain it from Sourceforge.net where you don't have to register. The link: https://sourceforge.net/projects/embarcadero-devcpp/
Post Reply