User forums > General (but related to Code::Blocks)
Helloworld.cpp wxWidgets Working ?
chrismac:
Has anyone got a working sample or helloworld wxWidgets program to compile ? Some seem to be out of date relative to the latest package 3.1.0, or is there a working version/s somewhere ?
stahta01:
To clarify are you talking about code created by the Code::Blocks wxWidgets Wizard or something else?
I am using Code::Blocks to build the wxWidgets (Git master branch) samples right now; some work and some samples do NOT.
I have NOT tested the wxWidgets Wizard with wxWidgets version 3.1; but, since it does NOT have an option to select version 3.1, I would guess that it would fail.
Tim S.
stahta01:
I am having a lot of problems building wxWidgets (Git master branch) samples using Static wxWidgets (Git master branch).
I had to add two libraries which I knew to add because I read it somewhere to reduce the linker errors.
But, it still had a linker error that looks like an wxWidgets bug.
The two libraries I added were "version" and "shlwapi".
The remaining linker error looks like an MinGW32 and wxWidgets bug. I am using MinGW32 TDM GCC version 4.7.1
--- Code: ---libwxmsw31ud_core.a(corelib_msw_checklst.o): In function `ZN18wxCheckListBoxItem10OnDrawItemER4wxDCRK6wxRectN16wxOwnerDrawnBase10wxODActionENS5_10wxODStatusE':
C:\SourceCode\OpenSourceCode\VC_Repos\Libs\wx\wxWidgets-git\build\msw/../../src/msw/checklst.cpp:162: undefined reference to `GetLayout@4'
--- End code ---
Now building wxWidgets 3.1.0 Static libs to see if the problem is new or old.
Edit: Looked at source code and the problem looks like a new wxWidgets and MinGW32 bug.
In other words, the final link error should NOT happen in wxWidgets version 3.1.0.
But, the link errors fixed by adding "version" and "shlwapi" will likely happen when using wxWidgets 3.1.0 and MinGW GCC.
Tim S.
chrismac:
helloworld.cpp -> http://docs.wxwidgets.org/trunk/overview_helloworld.html
I've moved to wxWidgets 2.8.12 (rather than 3.1.0) as 2.8.12 seems to work for others -> wxMSW-2.8.12-Setup.exe
and I'm trialling tdm-gcc-5.1.0-3.exe as it's developer seems to have confirmed it works with wx 2.8.12 -> re http://forums.codeblocks.org/index.php/topic,20382.0.html
Do others successfully use wxMSW-2.8.12-Setup.exe or wxWidgets-2.8.12.zip ?
// wxWidgets "Hello world" Program
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
void OnHello(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE();
};
enum
{
ID_Hello = 1
};
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Hello, MyFrame::OnHello)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( "Hello World", wxPoint(50, 50), wxSize(450, 340) );
frame->Show( true );
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
"Help string shown in status bar for this menu item");
menuFile->AppendSeparator();
menuFile->Append(wxID_EXIT);
wxMenu *menuHelp = new wxMenu;
menuHelp->Append(wxID_ABOUT);
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
menuBar->Append( menuHelp, "&Help" );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );
}
void MyFrame::OnExit(wxCommandEvent& event)
{
Close( true );
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
wxMessageBox( "This is a wxWidgets' Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION );
}
void MyFrame::OnHello(wxCommandEvent& event)
{
wxLogMessage("Hello world from wxWidgets!");
}
chrismac:
Here's a tutorial that apparently gets wxWidgets in CB to work.
https://forums.wxwidgets.org/viewtopic.php?f=19&t=42121&p=170561#p170561
Navigation
[0] Message Index
[#] Next page
Go to full version