Page 1 of 1

Strange undefined reference to wxXmlResource

Posted: Tue Jul 07, 2009 5:29 am
by sunose
Hi All:

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"));
}
after compileed ,when link phase get follow error:

||=== 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;
}
why generate this issue and how to avoid this issue?

thank in advice.

Posted: Tue Jul 07, 2009 7:49 am
by Muetdhiver
Hello, during your link phase, did you link with wxXRC ?

Bye.

Posted: Thu Jul 09, 2009 1:55 am
by sunose
Muetdhiver wrote:Hello, during your link phase, did you link with wxXRC ?

Bye.
yes,unicode enabled XRC static lib libwxmsw28u_xrc.a is linked correct.

Posted: Tue Aug 04, 2009 7:21 am
by sunose
this has been solved:

just include pair header file both in a file:

#include <wx/msw/winundef.h>
#include <wx/xrc/xmlres.h>


winundef.h must be before xmlres.h

this issue come with unicode enabled.