After pondering and wondering, I have decided to go for wxWidgets. Here is my first trial application. After running a test app from zetcode.com in my Code::Blocks & wxWidgets and I confirmed that it is fine! Then I tried to write my own app as shown below but I ran errors. Please correct me wher I have gone wrong, and any suggestion in the code. I'm just starting with wxWidgets
Cheers :)

#include <wx/wx.h>
class MyApp : public wxApp
{
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
    public:
        MyFrame(const wxString& title);
};

IMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    wxFrame *newFrame = new wxFrame(wxT("Hello Mary!"));
    newFrame->Show();
    return true;
}

MyFrame::MyFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
  Centre();
}

Errors:

C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|1|wx/wx.h: No such file or directory|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|3|error: expected class-name before '{' token|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|8|error: expected class-name before '{' token|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|10|error: expected `,' or `...' before '&' token|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|10|error: ISO C++ forbids declaration of `wxString' with no type|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|13|error: expected constructor, destructor, or type conversion before ';' token|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp||In member function `virtual bool MyApp::OnInit()':|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|error: `wxFrame' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|error: `newFrame' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|error: `wxFrame' is not a type|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|error: `wxT' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|warning: unused variable 'wxFrame'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|17|warning: unused variable 'wxT'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|22|error: expected `,' or `...' before '&' token|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: ISO C++ forbids declaration of `wxString' with no type|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp||In constructor `MyFrame::MyFrame(int)':|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: class `MyFrame' does not have any field named `wxFrame'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: `NULL' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: `wxID_ANY' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: `title' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: `wxDefaultPosition' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|error: `wxSize' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|25|error: `Centre' was not declared in this scope|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|25|warning: unused variable 'Centre'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|warning: unused variable 'NULL'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|warning: unused variable 'wxID_ANY'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|warning: unused variable 'title'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|warning: unused variable 'wxDefaultPosition'|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\myfirst\main.cpp|23|warning: unused variable 'wxSize'|
||=== Build finished: 19 errors, 8 warnings ===|

Recommended Answers

All 4 Replies

Compare your project settings, specifically things like additional include search paths, library search paths and libraries.

Doesn't code::blocks come with a "new wxwidgets" project tool to set all this up for you?

It doesn't compile with VC++ 2008 Express either. The compiler didn't like the preprocessor directive on line 1002, chkconf.h. So I changed it to this:

#ifdef wxUSE_CRASHREPORT
#if !wxUSE_ON_FATAL_EXCEPTION
#   ifdef wxABORT_ON_CONFIG_ERROR
#       error "wxUSE_CRASHREPORT requires wxUSE_ON_FATAL_EXCEPTION"
#   else
#       undef wxUSE_CRASHREPORT
#       define wxUSE_CRASHREPORT 0
#   endif
#endif /* wxUSE_CRASHREPORT */
#endif

After that, the compiler issued the error message on line 1819. error "wxClipboard requires wxDataObject"

Ok, I realize that. I used console instead of wxWidgets. Really I jumped on broken glass and guess what? :)

Now When I compile it gives me some sort of errors

C:\Documents and Settings\smtangoo\My Documents\C++ projects\steve\steveApp.cpp||In member function `virtual bool MyApp::OnInit()':|
C:\Documents and Settings\smtangoo\My Documents\C++ projects\steve\steveApp.cpp|17|error: no matching function for call to `wxFrame::wxFrame(const wchar_t[12])'|
C:\Program Files\CodeBlocks\wxWidgets-2.8.10\include\wx\msw\frame.h|168|note: candidates are: wxFrame::wxFrame(const wxFrame&)|
C:\Program Files\CodeBlocks\wxWidgets-2.8.10\include\wx\msw\frame.h|27|note: wxFrame::wxFrame(wxWindow*, wxWindowID, const wxString&, const wxPoint&, const wxSize&, long int, const wxString&)|
C:\Program Files\CodeBlocks\wxWidgets-2.8.10\include\wx\msw\frame.h|19|note: wxFrame::wxFrame()|
||=== Build finished: 1 errors, 0 warnings ===|

Ok I messed up line 17, it should have been

MyFrame *newFrame = new MyFrame(wxT("Hello Mary!"));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.