User forums > Help
redefinition of wxFrame & wxApp
Danishx83:
I am trying wxWidgets ( 2.8 ) on C::B ( 10.5 ), created a new project, setup every thing as shown by many guides / tutorials. When I try to compile, it gives two warnings
* error : redefinition of wxFrame
* error : redefinition of wxApp
in wxMain.h
--- Code: ---class wxFrame : public wxFrame {
//constr
//distor
//few funct
//few static const
//a pointer
};
--- End code ---
in wxApp.h
--- Code: ---class wxApp : public wxApp {
//OnInit function
};
--- End code ---
All the code is auto generated, as I am just starting to learn wxWidgets
oBFusCATed:
Isn't it obvious?
Your derived class must not have the same name as the base class. Rename wxFrame to something else and it will be fine.
I guess you'll have to run the wxsmith wizard once again...
Danishx83:
Yes I tried that before but there were many more errors, :-[
Now I changed them again
in wxMain.h
--- Code: ---class MywxFrame : public wxFrame {
//constr MywxFrame
//distor MywxFrame
//few funct
//few static const
//a pointer
};
--- End code ---
in wxMain.cpp
respective changes
in wxApp.h
--- Code: ---class MywxApp : public wxApp {
//OnInit function
};
--- End code ---
in wxApp.cpp
respective changes
The thing that made it work was changing
--- Code: ---BEGIN_EVENT_TABLE(wxFrame, wxFrame){} //error (auto generated code)
--- End code ---
to
--- Code: ---BEGIN_EVENT_TABLE(MywxFrame, wxFrame){} //Correct
--- End code ---
which previously I did was
--- Code: ---BEGIN_EVENT_TABLE(MywxFrame, MywxFrame){} //error
--- End code ---
in wxMain.cpp
So all this implies that the auto generated code has error, how do I correct it, so next time I create a new project and don't have to do all this.
oBFusCATed:
Please explain all the step you take to make a new project.
You've made an error somewhere and this will help us see what you're doing wrong.
Editing the existing project is a bit pointless. You can replace all the references to wxFrame and wxApp in the wxs files created by the wizard.
But this is not needed and creating project should work out of the box.
Danishx83:
File > New > Project
wxWidgets
wxWidgets 2.8.x
Project title "wx" <-------------Problem creator :o, caught it, but the template must cater for newbies like me
Auth Name "danishx83"
PrefGUIbuild -> wxSmith, Apptype -> FrameBased
wxWidgets Loc-> $(#wx) = "C:\wxWidgets2.8"
Compiler-> MinGW, Debug = Yes, Release = Yes
wxWidgetsLibSet-> Use DLL = Yes, monolithic = Yes, Unicode = Yes
Misc -> PCH = Yes
Files
wxApp.cpp
wxMain.cpp
wx_pch.h
wxApp.h
wxMain.h
resources.rc
xframe.wxs
@oBFusCATed: Thank You
Navigation
[0] Message Index
[#] Next page
Go to full version