[wxWidget2.6.3, Debian testing, G++ 4.2.1] Hello World with Segment Fault Problem

Julian Smart julian at anthemion.co.uk
Sat Oct 20 04:02:12 PDT 2007


Hi,

I don't think zero is a valid menu identifier number. However, this may 
not be related to the problem.

I suggest you use a version of wxWidgets that has debugging information, 
and then you can find out where the problem is happening by running 
under e.g. gdb. So the best bet is to get wxWidgets 2.8.6 from 
www.wxwidgets.org and compile for debugging, e.g.

tar xvfz wxGTK-2.8.6.tar.gz
cd wxGTK-2.8.6
mkdir build-debug
cd build-debug
../configure --with-gtk --enable-debug --enable-debug_gdb
make
cd samples/minimal
make
./minimal

To compile your own apps, you can use one of the wxWidgets IDEs to 
generate a suitable skeleton and makefile - one of which is 
DialogBlocks, which will also compile wxWidgets for you 
(www.anthemion.co.uk/dialogblocks).

Regards,

Julian

hpeter wrote:
> Hello Everybody:
>
>     I'm a wxWidget newbie, when I follow the tutorial in the wxwidget
> website and i got a segment fault when i close the window, I'm using
> Debian testing,  wxWidget ver is 2.6.3.2.1.5(Debian testing package),
> the following is the code:
>
> wxTestApp.h
> ==========================
> #include "wx/wx.h"
> #include "wxTestFrame.h"
>
> #ifndef _WXTEST_APP_H
> #define _WXTEST_APP_H
>
> class wxTestApp : public wxApp
> {
>     virtual bool OnInit();
> };
>
> //IMPLEMENT_APP_NO_MAIN(wxTestApp)
> IMPLEMENT_APP(wxTestApp)
> #endif
> ==========================
>
>
> wxTestApp.cpp
> ==========================
> #include "wxTestApp.h"
>
> bool wxTestApp::OnInit()
> {
>     wxTestFrame *frame = new wxTestFrame(_T("Hello World"),
> wxPoint(50,50), wxSize(450,340) );
>     frame->Show(TRUE);
>     SetTopWindow(frame);
>     return TRUE;
> }
> ==========================
>
> wxTestFrame.h
> ==========================
> #include "wx/wx.h"
>
> #ifndef _WXTEST_FRAME_H
> #define _WXTEST_FRAME_H
>
> class wxTestFrame: public wxFrame
> {
> public:
>     wxTestFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
>
>     void OnQuit(wxCommandEvent& event);
>     void OnAbout(wxCommandEvent& event);
>
>     DECLARE_EVENT_TABLE()
> };
>
> #endif
> ==========================
>
> wxTestFrame.cpp
> ==========================
> #include "wxTestFrame.h"
>
> typedef enum
> {
>     wxID_QUIT = 0,
>
> };
>
>
> BEGIN_EVENT_TABLE(wxTestFrame, wxFrame)
>     EVT_MENU(wxID_QUIT, wxTestFrame::OnQuit)
> END_EVENT_TABLE()
>
> wxTestFrame::wxTestFrame(const wxString& title, const wxPoint& pos,
> const wxSize& size)
> : wxFrame((wxFrame *)NULL, -1, title, pos, size)
> {
>     wxMenu *menuFile = new wxMenu;
>
>     menuFile->AppendSeparator();
>     menuFile->Append( wxID_QUIT, _T("E&xit") );
>
>     wxMenuBar *menuBar = new wxMenuBar;
>     menuBar->Append( menuFile, _T("&File") );
>
>     SetMenuBar( menuBar );
>
>     CreateStatusBar();
>     SetStatusText( _T("Welcome to wxWidgets!") );
> }
>
> void wxTestFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
> {
>     Close(TRUE);
> }
> ==========================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
>
>   


-- 
Julian Smart, Anthemion Software Ltd.
28/5 Gillespie Crescent, Edinburgh, Midlothian, EH10 4HU
www.anthemion.co.uk | +44 (0)131 229 5306
Tools for writers: www.writerscafe.co.uk
wxWidgets RAD:     www.anthemion.co.uk/dialogblocks





More information about the wx-users mailing list