I am using code;:block 8.0.2 and wxwidget 2.8.10 and mingw (gcc version 3.4.5 (mingw-vista special r3))
use new wxWidgets Project Wizard to create a new project ,using unicode mode.
the wxWidgets 2.8.10 has use UNICODE=1 and USE_GUI=1 build lib with BUILD=release and BUILD=debug to generate two version static lib.
the lib is ok.
now I want to load icon from xrc file,wxrc file work fine and generate the code and head file using wxrc /c /e.
in code has follow Snippets code:
Code: Select all
wxwidgets:
wxXmlResource::Get()->InitAllHandlers();
wxIcon moneypig=wxXmlResource::Get()->LoadIcon(wxT("Money_Pig.ico"));
wxIcon money=wxXmlResource::Get()->LoadIcon(wxT("Money.ico"));
but one class constructure,compile is ok,link has undefined reference error:
wxwidgets:
Code: Select all
testXRCInClassFrame::testXRCInClassFrame(wxFrame *frame)
: GUIFrame(frame)
{
#if wxUSE_STATUSBAR
statusBar->SetStatusText(_("Hello Code::Blocks user!"), 0);
statusBar->SetStatusText(wxbuildinfo(short_f), 1);
#endif
wxXmlResource::Get()->InitAllHandlers();
wxIcon moneypig=wxXmlResource::Get()->LoadIcon(wxT("Money_Pig.ico"));
wxIcon money=wxXmlResource::Get()->LoadIcon(wxT("Money.ico"));
}
||=== testXRCInClass, Release ===|
obj\Release\testXRCInClassMain.o:testXRCInClassMain.cpp|| undefined reference to `wxXmlResource::Get()'|
obj\Release\testXRCInClassMain.o:testXRCInClassMain.cpp|| undefined reference to `wxXmlResource::InitAllHandlers()'|
...........<skip some error>
||=== Build finished: 12 errors, 0 warnings ===|
but when move the code to App.cpp
link is work.code is follow:
wxwidgets:
Code: Select all
bool testXRCInClassApp::OnInit()
{
wxXmlResource::Get()->InitAllHandlers();
wxIcon moneypig=wxXmlResource::Get()->LoadIcon(wxT("Money_Pig.ico"));
wxIcon money=wxXmlResource::Get()->LoadIcon(wxT("Money.ico"));
testXRCInClassFrame* frame = new testXRCInClassFrame(0L);
frame->SetIcon(wxICON(aaaa)); // To Set App Icon
frame->Show();
return true;
}
thank in advice.