Author Topic: wxFormBuilder generated classes and using them within code::blocks  (Read 9175 times)

Offline blue orb

  • Multiple posting newcomer
  • *
  • Posts: 25
i can't get the files generated by wxFormBuilder to work. when i add these wfb-generated .cpp and .h files to the active project, in code::blocks, i get more errors. do i need resource files? what are rs files?

btw, wxWidgets projects compile/run fine and all is ok there. so that's something!

however, wxsmith content still won't compile and is giving error messages about missing headers.

i have now tried three seperate compilers (minGW 32-bit, minGW 64-bit and that dw2 gcc compiler.

i am a noob, yet this just gets more and more complicated... ;)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6636
    • My Best Post
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #1 on: November 04, 2011, 01:31:12 pm »
Error messages have meaning; I suggest reading them.
You might even post them.

Your problem is likely an Compiler/Linker problem instead of a Code::Blocks problem; without the errors, I can only guess it is user caused problem.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline blue orb

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #2 on: November 04, 2011, 01:56:18 pm »
here's the error messages and the code

the compiler errors
----------------------

Code: [Select]
||=== pluto, Debug ===|
I:\My Documents\CodeBlocks C++\pluto\zero.h|11|error: wx/artprov.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|12|error: wx/xrc/xmlres.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|13|error: wx/string.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|14|error: wx/frame.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|15|error: wx/gdicmn.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|16|error: wx/font.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|17|error: wx/colour.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|18|error: wx/settings.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|19|error: wx/textctrl.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|20|error: wx/button.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|21|error: wx/sizer.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|22|error: wx/panel.h: No such file or directory|
I:\My Documents\CodeBlocks C++\pluto\zero.h|31|error: expected class-name before '{' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|38|error: expected ')' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|48|error: expected class-name before '{' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|52|error: ISO C++ forbids declaration of 'wxTextCtrl' with no type|
I:\My Documents\CodeBlocks C++\pluto\zero.h|52|error: expected ';' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|53|error: ISO C++ forbids declaration of 'wxButton' with no type|
I:\My Documents\CodeBlocks C++\pluto\zero.h|53|error: expected ';' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|54|error: ISO C++ forbids declaration of 'wxButton' with no type|
I:\My Documents\CodeBlocks C++\pluto\zero.h|54|error: expected ';' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zero.h|58|error: expected ')' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zeroMyFrame1.h|18|error: expected ')' before '*' token|
I:\My Documents\CodeBlocks C++\pluto\zeroMyFrame1.cpp|3|error: expected ')' before '*' token|
||=== Build finished: 24 errors, 0 warnings ===|



the .cpp files
---------

Code: [Select]
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __ZERO_H__
#define __ZERO_H__

#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/panel.h>

///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
/// Class MyFrame1
///////////////////////////////////////////////////////////////////////////////
class MyFrame1 : public wxFrame
{
private:

protected:

public:

MyFrame1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("zero"), const wxPoint& pos = wxPoint( 100,100 ), const wxSize& size = wxSize( 600,400 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );

~MyFrame1();

};

///////////////////////////////////////////////////////////////////////////////
/// Class MyPanel1
///////////////////////////////////////////////////////////////////////////////
class MyPanel1 : public wxPanel
{
private:

protected:
wxTextCtrl* m_textCtrl1;
wxButton* m_button1;
wxButton* m_button2;

public:

MyPanel1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,400 ), long style = wxTAB_TRAVERSAL );
~MyPanel1();

};

#endif //__ZERO_H__



Code: [Select]
#include "zeroMyFrame1.h"

zeroMyFrame1::zeroMyFrame1( wxWindow* parent )
:
MyFrame1( parent )
{

}



Code: [Select]
#include "zeroMyPanel1.h"

zeroMyPanel1::zeroMyPanel1( wxWindow* parent )
:
MyPanel1( parent )
{

}



the .h files
------------


Code: [Select]
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __ZERO_H__
#define __ZERO_H__

#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/panel.h>

///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
/// Class MyFrame1
///////////////////////////////////////////////////////////////////////////////
class MyFrame1 : public wxFrame
{
private:

protected:

public:

MyFrame1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("zero"), const wxPoint& pos = wxPoint( 100,100 ), const wxSize& size = wxSize( 600,400 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );

~MyFrame1();

};

///////////////////////////////////////////////////////////////////////////////
/// Class MyPanel1
///////////////////////////////////////////////////////////////////////////////
class MyPanel1 : public wxPanel
{
private:

protected:
wxTextCtrl* m_textCtrl1;
wxButton* m_button1;
wxButton* m_button2;

public:

MyPanel1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,400 ), long style = wxTAB_TRAVERSAL );
~MyPanel1();

};

#endif //__ZERO_H__



Code: [Select]
#ifndef __zeroMyFrame1__
#define __zeroMyFrame1__

/**
@file
Subclass of MyFrame1, which is generated by wxFormBuilder.
*/

#include "zero.h"

//// end generated include

/** Implementing MyFrame1 */
class zeroMyFrame1 : public MyFrame1
{
public:
/** Constructor */
zeroMyFrame1( wxWindow* parent );
//// end generated class members

};

#endif // __zeroMyFrame1__



Code: [Select]
#ifndef __zeroMyPanel1__
#define __zeroMyPanel1__

/**
@file
Subclass of MyPanel1, which is generated by wxFormBuilder.
*/

#include "zero.h"

//// end generated include

/** Implementing MyPanel1 */
class zeroMyPanel1 : public MyPanel1
{
public:
/** Constructor */
zeroMyPanel1( wxWindow* parent );
//// end generated class members

};

#endif // __zeroMyPanel1__



i presume it is something fundamental that i am doing wrong. the problem seems to be the missing header files/other. i am just about stuck... any ideas?

thanks!
 

zabzonk

  • Guest
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #3 on: November 04, 2011, 02:01:08 pm »
I thought we went through all this yesterday? You have to tell codeblocks the location of the wxwidgets installation!

And BTW, names beginning with double underscores or underscores and uppercase letters are not allowed in user C++ code - they are reserved for the C++ implementation.
« Last Edit: November 04, 2011, 02:09:28 pm by Neil Butterworth »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #4 on: November 04, 2011, 02:03:42 pm »
...in addition: Having characters like "+" in the path might sooner or later cause errors, too. For development, I'd suggest you prefer simple path names (letters and numbers), probably even without spaces to avoid conflicts across platforms. Of course, this does not apply for the runtime version of your application.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline blue orb

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #5 on: November 04, 2011, 02:08:30 pm »
okay, as said, a wxWidgets project works fine...

but a wxsmith project still doesn't compiile.

i have told code::blocks where the wxWidgets (wxPack) is and that works fine with a new wxWidgets project. alas, wxsmith projects still don't compile.

the differences between wxWidgets and wxsmith are beginning to blur on me.

i might give this up ;)

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #6 on: November 05, 2011, 10:35:06 am »
wxWidgets headers have not been found at all, even if they are in "<>". Check what is produced by wx-config --cxxflags and wx-config --libs. If your headers (and libraries) are elsewhere, add paths to your headers (and libraries) to Build Options of your project. You can also create a "custom project" which will be wxWidgets project along with the right paths to your headers. The problem does not seem to be caused by wxFormBuilder.

The underscores are okay. They aren't around names of variables but around #define symbols, where underscores are used frequently.

zabzonk

  • Guest
Re: wxFormBuilder generated classes and using them within code::blocks
« Reply #7 on: November 05, 2011, 10:52:09 am »
> The underscores are okay. They aren't around names of variables but around #define symbols, where underscores are used frequently.

Perhaps you should read the C and C++ standards before giving advice like this? Names like that are NOT OK. To quote from the C Standard:

> All identifiers that begin with an underscore are always reserved for use as macros and as identifiers with file scope in both the ordinary and tag name spaces.

and:

> All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.


Here "reserved" means "reserved for the C (or C++) compiler implementers".
« Last Edit: November 05, 2011, 10:56:10 am by Neil Butterworth »