Menu

wxWidgets Linker error

Anonymous
2008-12-19
2012-09-26
  • Anonymous

    Anonymous - 2008-12-19

    I'm trying to compile a simple wxApp:

    include <wx/wx.h>

    class MainApp : public wxApp {
    public:
    virtual bool OnInit();
    };

    bool MainApp::OnInit() {
    wxFrame *content = new wxFrame(NULL, wxID_ANY, wxT("Hello cliche! Hello wxWidgets"), wxDefaultPosition, wxSize(350,150));
    content->Show(true);

     return true;
    

    }

    IMPLEMENT_APP(MainApp)

    But get a bunch of errors similar to the following:

    [Linker error] undefined reference to wxFrameNameStr' [Linker error] undefined reference towxDefaultPosition'

     
    • cpns

      cpns - 2008-12-26

      First do not put your projects in folders containing spaces. My Documents resolves to "C:\Documents and Settings\Jordan\My Documents\&quot; in you case, which clearly contains spaces. Read the "PLEASE READ BEFORE POSTING A QUESTION" thread for more info.

      The following line:

      g++.exe "C:\Documents and Settings\Jordan\My Documents\Development\C++\Practise\test.cpp" -o "C:\Documents and Settings\Jordan\My Documents\Development\C++\Practise\test.exe" -I"C:\Env\wxMSW-2.8.9\include" -L"C:\Env\wxMSW-2.8.9"

      is the invokation of teh linker for your project. Although you have added a search path or the wxWidget library, you have not explicitly linked any additional libraries. This is also dealt with in the "PLEASE READ BEFORE POSTING A QUESTION".

      Clifford

       
    • cpns

      cpns - 2008-12-19

      Post the log as mentioned in the "PLEASE READ BEFORE POSTING A QUESTION" thread an almost every post of the forum where it is not provided!

      You have correctly identified it as a linker error, yet posted the code. The code by definition is valid, since it must have compiled for the linker to be invoked. Almost certainly you failed to link the wxWidgets library; which the log would have indicated without you getting flamed! ;-)

      Clifford

       
    • Anonymous

      Anonymous - 2008-12-26

      Here is my log:

      Compiler: Mingw32
      Executing g++.exe...
      g++.exe "C:\Documents and Settings\Jordan\My Documents\Development\C++\Practise\test.cpp" -o "C:\Documents and Settings\Jordan\My Documents\Development\C++\Practise\test.exe" -I"C:\Env\wxMSW-2.8.9\include" -L"C:\Env\wxMSW-2.8.9"
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text+0x89): undefined reference to wxFrameNameStr' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text+0xe7): undefined reference towxDefaultPosition'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text+0x294): undefined reference to wxAppConsole::CheckBuildOptions(char const*, char const*)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text+0x33a): undefined reference towxEntry(HINSTANCE*, HINSTANCE, char, int)'

      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$ZN7wxFrameC1EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x43): undefined reference to wxFrameBase::wxFrameBase()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN7wxFrameC1EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&amp;, wxPoint const&amp;, wxSize const&amp;, long, wxString const&amp;)]+0x4c): undefined reference tovtable for wxFrame'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$ZN7wxFrameC1EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x5e): undefined reference to wxFrame::Init()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN7wxFrameC1EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&amp;, wxPoint const&amp;, wxSize const&amp;, long, wxString const&amp;)]+0x9a): undefined reference towxFrame::Create(wxWindow, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$ZN7wxFrameC1EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0xbd): undefined reference to wxFrameBase::~wxFrameBase()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x7): undefined reference towxStringBase::npos'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to wxStringBase::InitWith(char const*, unsigned int, unsigned int)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN7MainAppC1Ev[MainApp::MainApp()]+0xd): undefined reference towxApp::wxApp()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN12wxAppConsole11GetInstanceEv[wxAppConsole::GetInstance()]+0x4): undefined reference to wxAppConsole::ms_appInstance' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x8): undefined reference towxApp::GetClassInfo() const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x14): undefined reference to wxObject::CreateRefData() const' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x18): undefined reference towxObject::CloneRefData(wxObjectRefData const
      ) const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x1c): undefined reference to `wxEvtHandler::ProcessEvent(wxEvent&)'

      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x20): undefined reference to wxEvtHandler::SearchEventTable(wxEventTable&amp;, wxEvent&amp;)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x28): undefined reference towxEvtHandler::TryParent(wxEvent&)'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x2c): undefined reference to wxApp::GetEventTable() const' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x30): undefined reference towxApp::GetEventHashTable() const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x34): undefined reference to wxEvtHandler::DoSetClientObject(wxClientData*)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x38): undefined reference towxEvtHandler::DoGetClientObject() const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x3c): undefined reference to wxEvtHandler::DoSetClientData(void*)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x40): undefined reference towxEvtHandler::DoGetClientData() const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x44): undefined reference to wxApp::Initialize(int&amp;, char**)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x50): undefined reference towxAppBase::OnInitGui()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x54): undefined reference to wxAppBase::OnRun()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x58): undefined reference towxAppBase::OnExit()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x5c): undefined reference to wxApp::CleanUp()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x64): undefined reference towxAppBase::Exit()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x68): undefined reference to wxAppBase::OnInitCmdLine(wxCmdLineParser&amp;)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x6c): undefined reference towxAppBase::OnCmdLineParsed(wxCmdLineParser&)'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x70): undefined reference to `wxAppConsole::OnCmdLineHelp(wxCmdLineParser&)'

      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x74): undefined reference to wxAppConsole::OnCmdLineError(wxCmdLineParser&amp;)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x78): undefined reference towxAppConsole::FilterEvent(wxEvent&)'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x7c): undefined reference to wxAppConsole::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&amp;), wxEvent&amp;) const' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x84): undefined reference towxAppConsole::ProcessPendingEvents()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x88): undefined reference to wxApp::Yield(bool)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x8c): undefined reference towxApp::WakeUpIdle()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x90): undefined reference to wxAppBase::CreateTraits()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x94): undefined reference towxAppBase::MainLoop()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x98): undefined reference to wxAppBase::ExitMainLoop()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0x9c): undefined reference towxAppBase::Pending()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xa0): undefined reference to wxAppBase::Dispatch()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xa4): undefined reference towxAppBase::ProcessIdle()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xa8): undefined reference to wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&amp;)' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xac): undefined reference towxApp::OnExceptionInMainLoop()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xb4): undefined reference to wxAppBase::GetTopWindow() const' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xb8): undefined reference towxAppBase::GetDisplayMode() const'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xc4): undefined reference to wxAppBase::GetLayoutDirection() const' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV7MainApp[vtable for MainApp]+0xc8): undefined reference towxAppBase::SetActive(bool, wxWindow*)'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]+0xc): undefined reference to wxThread::TestDestroy()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN12wxAppConsole22SetInitializerFunctionEPFPS_vE[wxAppConsole::SetInitializerFunction(wxAppConsole* (*)())]+0x7): undefined reference towxAppConsole::ms_appInitFn'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN20wxThreadHelperThreadD1Ev[wxThreadHelperThread::~wxThreadHelperThread()]+0x16): undefined reference to wxThread::~wxThread()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN20wxThreadHelperThreadD0Ev[wxThreadHelperThread::~wxThreadHelperThread()]+0x16): undefined reference towxThread::~wxThread()'
      C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN7MainAppD1Ev[MainApp::~MainApp()]+0x16): undefined reference to wxApp::~wxApp()' C:\DOCUME~1\Jordan\LOCALS~1\Temp/ccPu3YnG.o:test.cpp:(.text$_ZN7MainAppD0Ev[MainApp::~MainApp()]+0x16): undefined reference towxApp::~wxApp()'
      collect2: ld returned 1 exit status

      Execution terminated

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.