i can compile c++ file using visual studio, but i wanna compile it using Mingw(gcc / g++).
Note: i don't know much about wxWidgets
when i run gcc main.cpp -I C:\wxWidgets-3.2.5\include\msvc -I C:\wxWidgets-3.2.5\include -L C:\wxWidgets-3.2.5\lib\vc_x64_lib -mwindows
it gives me this error message
In file included from C:\wxWidgets-3.2.5\include/wx/platform.h:159:0, from C:\wxWidgets-3.2.5\include/wx/defs.h:45, from C:\wxWidgets-3.2.5\include/wx/wx.h:14, from main.cpp:1: C:\wxWidgets-3.2.5\include\msvc/wx/setup.h:12:6: error: #error "This file should only be included when using Microsoft Visual C++" #error "This file should only be included when using Microsoft Visual C++" ^~~~~ In file included from C:\wxWidgets-3.2.5\include/wx/platform.h:159:0, from C:\wxWidgets-3.2.5\include/wx/defs.h:45, from C:\wxWidgets-3.2.5\include/wx/wx.h:14, from main.cpp:1: C:\wxWidgets-3.2.5\include\msvc/wx/setup.h:142:27: fatal error: ../../../lib/vc_lib/msw/wx/setup.h: No such file or directory #include wxSETUPH_PATH_STR ^ compilation terminated.
but i don't want to use Microsoft Visual studio. i prefer to compile it using Mingw(g++ / gcc) or from a makefile
the code i tried to compile, it's a simple hello world program that i got from internet. it works perfectly with Microsoft Visual studio when i tried to compile.
#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);
For convenience, you can download the precompiled binaries from wxWidgets' official site. Note that you must download those for gcc for a specific version. If you want to use hand-write Makefiles, you need to use the following commands:
g++ main.cpp -pipe -I C:\wxWidgets-3.2.5\include -I C:\wxWidgets-3.2.5\lib\gcc810_x64_dll\mswu -L C:\wxWidgets-3.2.5\lib\gcc810_x64_dll -mwindows -lwxbase32u -lwxmsw32u_core