Hello everyone.
I'm trying to learn how to use wxWidgets using www.3dbuzz.com C++ Video training. They show you how to install wxwidgets, and what you need to do before using it. The thing is, they use Visual Studio, not Code::Blocks, and I can't exactly follow along the setup.
At some point in time, they go to "Project Properties->C/C++->Preprocesor" and then add:
wxUSE_GUI=1; _WXDEBUG_; WXDEBUG=1
And I can't find "preprocesor" anywhere on codeblocks :)
I tried going along, but... let me show you my code.
#include "wx/wx.h"
class HelloWorldApp : wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(HelloWorldApp)
bool HelloWorldApp::OnInit()
{
wxFrame *frame = new wxFrame((wxFrame *) NULL, -1, _T("Hello World!"), wxPoint(60,70), wxSize(500,600));
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
if I try to compile it, it gives me this error:
'wxAppConsole is an inaccessible base of HelloWorldApp', and it says it's on the
IMPLEMENT_APP(HelloWorldApp) line, so I imagine it has something to do with the preprocesor. I don't know, though.
Can someone help me?
Thanks!!
QuoteAt some point in time, they go to "Project Properties->C/C++->Preprocesor" and then add:
wxUSE_GUI=1; _WXDEBUG_; WXDEBUG=1
And I can't find "preprocesor" anywhere on codeblocks
It's "Project->Build options->Compiler options->Compiler definitions" :)
Oh, and enter them one-per line like this:
wxUSE_GUI=1
_WXDEBUG_
WXDEBUG=1Yiannis.
Thanks!
But still, I got the error... :D any ideas?
At some point, they use "wxmswd.lib", and I didn't find that in my computer. I added "wxmsw242.dll" that was in the codeblocks dir :D
Any ideas?
I have wxwidgets 2.6, and MinGW.
dumb me, i'm missing a ;
Anyway, it still doesn't work. It now tells me "variable 'vtable for wxFrame' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details."
But that just means I have to read a little...
QuoteAt some point, they use "wxmswd.lib", and I didn't find that in my computer. I added "wxmsw242.dll" that was in the codeblocks dir
Put libwxmsw24.a (or libwxmsw242.a?) in linker options, not wxmsw242.dll
Yiannis.
nope, not found that file.
Searched for lib*.a
I have:
libwx_base-2.6.dll.a
libwx_base_net-2.6.dll.a
libwx_base_xml-2.6.dll.a
libwx_msw_adv-2.6.dll.a
libwx_msw_core-2.6.dll.a
libwx_msw_html-2.6.dll.a
libwx_msw_media-2.6.dll.a
libwx_msw_qa-2.6.dll.a
libwx_msw_xrc-2.6.dll.a
libwxexpat-2.6.a
libwxjpeg-2.6.a
libwxpng-2.6.a
libwxregex-2.6.a
libwxtiff-2.6.a
libwxzlib-2.6.a
I've tried with base, core and adv. (since those are the ones that sound more... tryable)
Maybe in 2.6 there is something different, maybe I just did something wrong when compiling wxwidgets?
Damn it, one full day lost trying to get a simple program to run...
There is a file called ld.exe inside of my mingw/bin folder. I ran "ld --help" and there IS an option to --enable-auto-import, but I don't know how to tell codeblocks to tell it to use it.
Try with libwx_msw_core-2.6.dll.a - that seems to be the one.
Unless I call both libwx_msw_core-2.6.dll.a and libwx_base-2.6.dll.a it gives me tons of compile errors of "undefined reference to..."
And if I call them both, then I get only 1 error. The vtable one.
Thanks!
hmmm try disabling the auto-import switch in GCC. add --disable-auto-import to your compiler (or linker?) switches. Then probably you'll get an undefined reference. But maybe it's some configuration error...
did you try to move libwx_base BEFORE libwx_msw_core, in your linker libraries?
Quotehmmm try disabling the auto-import switch in GCC. add --disable-auto-import to your compiler (or linker?) switches. Then probably you'll get an undefined reference. But maybe it's some configuration error...
Okay, that could work... I'll try it when I get home.
Quotedid you try to move libwx_base BEFORE libwx_msw_core, in your linker libraries?
Nope... I'll try it too.
Thanks!!
Look, if you're so frustrated, you can download the 2.4.2 version of wxwidgets (works for me - and I tried to compile Codeblocks with 2.6, but got an autoimport error in stc). So the problem must be obviously a setup problem.
And don't worry about "one full day for a simple program", don't think like that. It's the wxwidgets installation, when you get that part done, you'll be writing hundreds of programs :) Don't give up!
It look to me like a simple probble fist of all did you complie wxwidget on the form like they say in installtion forms at
http://www.codeblocks.org/index.php?name=PNphpBB2&file=viewtopic&t=270
This would give you the need files. Just rember when you do this add the gcc compiler(gcc.exe) dir to your path. Then use there template in codeblocks for wxwidgets. Don't forget to select dynamic. If you want static you have to read wxwidgets install.txt .
If you can't find gcc.exe you download the wrong version of C:B download the one that contane it read what they have there it sayes witch one has it.
One more thing don't feel stupid on programing. It is very common for pepole to have problem when starting out add I am verry glade to help.
Sorry I forgot you are use microsoft. This is for gcc but you might want to try Gcc first it would make you life easer. Want i was trying to say above you need to get wxwidget and compile so you have the needed(.lib or (.a if use gcc ming)) files or you can't program with it. WxWidget is not include with codeblock it is another program.
This thread is ancient (13+ years old), but here is a fix for you anyway:
Change:
class HelloWorldApp : wxApp
into
class HelloWorldApp : public wxApp
and you are good to go.
Quote from: Xorlium on April 23, 2005, 03:34:23 PM
Hello everyone.
I'm trying to learn how to use wxWidgets using www.3dbuzz.com C++ Video training. They show you how to install wxwidgets, and what you need to do before using it. The thing is, they use Visual Studio, not Code::Blocks, and I can't exactly follow along the setup.
At some point in time, they go to "Project Properties->C/C++->Preprocesor" and then add:
wxUSE_GUI=1; _WXDEBUG_; WXDEBUG=1
And I can't find "preprocesor" anywhere on codeblocks :)
I tried going along, but... let me show you my code.
#include "wx/wx.h"
class HelloWorldApp : wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(HelloWorldApp)
bool HelloWorldApp::OnInit()
{
wxFrame *frame = new wxFrame((wxFrame *) NULL, -1, _T("Hello World!"), wxPoint(60,70), wxSize(500,600));
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
if I try to compile it, it gives me this error:
'wxAppConsole is an inaccessible base of HelloWorldApp', and it says it's on the
IMPLEMENT_APP(HelloWorldApp) line, so I imagine it has something to do with the preprocesor. I don't know, though.
Can someone help me?
Thanks!!