Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Help compiling a simple beginners program

(1/2) > >>

mrpringle:
Hi,
I"m just trying to get the hang of wxWiidgets. There's a few things I don't understand, and I've had trouble compiling a basic application from scratch.
I'm using wxWidgets 2.8.0. I've got a fair understanding of command-line c++ programming, but never dealt with GUI's before.

I'm getting an error when compiling my project which says:
Basic.cpp:: undefined reference to `vtable for BasicFrame'
Basic.cpp:: undefined reference to `vtable for BasicFrame'
:: === Build finished: 2 errors, 0 warnings ===



Here is Basic.h
#ifndef BASIC_H
#define BASIC_H

class Basic: public wxApp
{
    public:
        virtual bool OnInit();
};

class BasicFrame: public wxFrame
{
    public:
        BasicFrame(const wxString & title, int xpos, int ypos, int width, int height);
        ~BasicFrame();
};
#endif

___________________________________________________________________
and here is Basic.cpp

#include "basic.h"
#include <wx/wx.h>

IMPLEMENT_APP(Basic)

bool Basic::OnInit()
{
    BasicFrame *frame = new BasicFrame(_("Sample"), 50,50,450,300);
    frame->Show();
    SetTopWindow(frame);
    return true;
}

BasicFrame::BasicFrame (const wxString & title, int xpos, int ypos, int width, int height)
: wxFrame(NULL, -1, title, wxPoint (xpos,ypos), wxSize (width, height))
{}



____________________________________________________________________________
For the moment I'm just trying to get a wxFrame showing, and then I'll mess around with event handling and controls, etc.

Another thing which I'm unsure about is the use of the _ symbol on this line:
BasicFrame *frame = new BasicFrame(_("Sample"), 50,50,450,300);
What does the _ in _("Sample") do?

I appreciate your time.

SamT:
I would suggest you to build up a very simple frame program by the wizard which included in C::B. Then check each line of the generated source.

I test the wizard in svn build rev 3461 and works fine for me.

mrpringle:
I got the wizard working, but I don't really understand all the code it generates, so I followed a tutorial off the internet.
Wizards are good, but I would prefer to learn the stuff line by line before I use the wizard.

mrpringle:
never mind. I worked out what was wrong.

SamT:
I would suggest you to study a book "Cross-Platform GUI Programming with wxWidgets" http://www.wxwidgets.org/docs/book/ However, could somebody tell me why there is only one book for wxWidgets? Did I miss something?

Navigation

[0] Message Index

[#] Next page

Go to full version