wxWidgets: g++ Fehlermeldung: undefined reference to



  • Hallo! Mal wieder scheitern meine Entwicklungen mit wxWidgets an mir unerklärlichen Problemen. Gefundene ähnliche Probleme im Forum und per Google haben mir nichts gebracht. Deswegen probiere ich es jetzt einfach nochmal so.

    Der Code sieht folgendermaßen aus:

    #include "wx/wx.h"
    
    //Declare the application class
    class MyApp : public wxApp {
        public:
            virtual bool OnInit(); //Called on application startup
    };
    
    //Declare the main frame class
    class MyFrame : public wxFrame {
        private:
            DECLARE_EVENT_TABLE();
    
        public:
            //Constructor
            MyFrame( const wxString& title );
    
            //Event handlers
            void OnAbout( wxCommandEvent& event );
            void OnQuit( wxCommandEvent& event );
    };
    
    IMPLEMENT_APP( MyApp )
    
    DECLARE_APP( MyApp )
    
    bool MyApp::OnInit() {
        //Create the main application window
        MyFrame* frame = new MyFrame( wxT("wxWidgets Killer App") );
    
        frame->Show( true );
    
        //Start the event loop
        return true;
    }
    
    BEGIN_EVENT_TABLE( MyFrame, wxFrame )
        EVT_MENU( wxID_ABOUT, MyFrame::OnAbout )
        EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
    END_EVENT_TABLE()
    
    void MyFrame::OnAbout( wxCommandEvent& event ) {
        wxString msg;
    
        msg = "Hallo und willkommen zu " wxVERSION_STRING;
    
        wxMessageBox( msg, wxT("Über wxWidgets Killer App"), wxOK | wxICON_INFORMATION, this );
    }
    
    void MyFrame::OnQuit( wxCommandEvent& event ) {
        Close();
    }
    
    MyFrame::MyFrame( const wxString& title ) : wxFrame( NULL, wxID_ANY, title ) {
        //Create a menu bar
        wxMenu* fileMenu = new wxMenu;
        wxMenu* helpMenu = new wxMenu;
    
        helpMenu->Append( wxID_ABOUT, wxT("&Über...\tF1"), wxT("Zeigt den Info-Dialog") ); //By default the help string is displayed in the status line
        fileMenu->Append( wxID_EXIT, wxT("&Beenden\tAlt-X"), wxT("Beendet das Programm") );
    
        wxMenuBar* menuBar = new wxMenuBar();
        menuBar->Append( fileMenu, wxT("&Programm") );
        menuBar->Append( helpMenu, wxT("&Hilfe") );
    
        SetMenuBar( menuBar );
    
        CreateStatusBar( 2 );
        SetStatusText( wxT("Willkommen zu wxWidgets!") );
    }
    

    Und beim Aufruf von g++ mit:

    g++.exe -Ic:/wxwidgets2.8/include -Ic:/wxwidgets2.8/contrib/include -D__WXMSW__ -mthreads -Ic:/wxwidgets2.8/buildud/lib/wx/include/msw-unicode-release-static-2.8 -o main.o main.cpp
    

    kommen die folgenden Fehlermeldungen:

    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x4c): undefined reference to `wxAppConsole::CheckBuildOptions(char const*, char const*)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0xf2): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x2ec): undefined reference to `wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x389): undefined reference to `wxWindowBase::Close(bool)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x3cc): undefined reference to `wxFrameNameStr'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x3f5): undefined reference to `wxDefaultSize'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x3fd): undefined reference to `wxDefaultPosition'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x728): undefined reference to `wxMenuBar::wxMenuBar()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x869): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x871): undefined reference to `wxStatusLineNameStr'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x8ad): undefined reference to `wxFrameBase::CreateStatusBar(int, long, int, wxString const&)'
    
    [...]
    
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0xfe7): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x10e9): undefined reference to `wxFrame::~wxFrame()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x116d): undefined reference to `wxEventHashTable::wxEventHashTable(wxEventTable const&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x11bd): undefined reference to `wxEVT_COMMAND_MENU_SELECTED'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x11fa): undefined reference to `wxEVT_COMMAND_MENU_SELECTED'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x1237): undefined reference to `wxEVT_NULL'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text+0x125a): undefined reference to `wxEventHashTable::~wxEventHashTable()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata+0x78): undefined reference to `wxFrame::sm_eventTable'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN5MyAppC1Ev[MyApp::MyApp()]+0xd): undefined reference to `wxApp::wxApp()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN12wxAppConsole11GetInstanceEv[wxAppConsole::GetInstance()]+0x4): undefined reference to `wxAppConsole::ms_appInstance'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x7): undefined reference to `wxStringBase::npos'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN8wxStringaSEPKc[wxString::operator=(char const*)]+0x14): undefined reference to `wxStringBase::operator=(char const*)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN12wxStringBase4InitEv[wxStringBase::Init()]+0x7): undefined reference to `wxEmptyString'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN10wxMenuBase6AppendEiRK8wxStringS2_10wxItemKind[wxMenuBase::Append(int, wxString const&, wxString const&, wxItemKind)]+0x31): undefined reference to `wxMenuItemBase::New(wxMenu*, int, wxString const&, wxString const&, wxItemKind, wxMenu*)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN6wxMenuC1El[wxMenu::wxMenu(long)]+0x53): undefined reference to `vtable for wxMenu'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN6wxMenuC1El[wxMenu::wxMenu(long)]+0x7a): undefined reference to `wxMenu::Init()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN6wxMenuC1El[wxMenu::wxMenu(long)]+0xc6): undefined reference to `wxMenuBase::~wxMenuBase()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN18wxAcceleratorArrayD1Ev[wxAcceleratorArray::~wxAcceleratorArray()]+0xd): undefined reference to `wxBaseArrayPtrVoid::~wxBaseArrayPtrVoid()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN18wxAcceleratorArrayC1Ev[wxAcceleratorArray::wxAcceleratorArray()]+0xd): undefined reference to `wxBaseArrayPtrVoid::wxBaseArrayPtrVoid()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN10wxMenuBaseC2El[wxMenuBase::wxMenuBase(long)]+0x43): undefined 
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN10wxListBaseC2E9wxKeyType[wxListBase::wxListBase(wxKeyType)]+0x45): undefined reference to `vtable for wxListBase'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN10wxListBaseC2E9wxKeyType[wxListBase::wxListBase(wxKeyType)]+0x5e): undefined reference to `wxListBase::Init(wxKeyType)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN8wxObjectD2Ev[wxObject::~wxObject()]+0xb): undefined reference to `vtable for wxObject'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN8wxObjectD2Ev[wxObject::~wxObject()]+0x16): undefined reference to `wxObject::UnRef()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN8wxObjectC2Ev[wxObject::wxObject()]+0x8): undefined reference to `vtable for wxObject'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x43): undefined reference to `wxFrameBase::wxFrameBase()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x4c): undefined reference to `vtable for wxFrame'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x5e): undefined reference to `wxFrame::Init()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0x9a): undefined reference to `wxFrame::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)]+0xbd): undefined reference to `wxFrameBase::~wxFrameBase()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x8): undefined reference to `wxFrame::GetClassInfo() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x14): undefined reference to `wxObject::CreateRefData() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x18): undefined reference to `wxObject::CloneRefData(wxObjectRefData const*) const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x1c): undefined reference to `wxEvtHandler::ProcessEvent(wxEvent&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x20): undefined reference to `wxEvtHandler::SearchEventTable(wxEventTable&, wxEvent&)'
    
    [...]
    
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x48): undefined reference to `wxWindow::SetLabel(wxString const&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x4c): undefined reference to `wxWindow::GetLabel() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x58): undefined reference to `wxWindow::GetLayoutDirection() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x5c): undefined reference to `wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x60): undefined reference to `wxWindow::AdjustForLayoutDirection(int, int, int) const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x64): undefined reference to `wxFrame::Raise()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x68): undefined reference to `wxWindow::Lower()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x6c): undefined reference to `wxFrame::GetClientAreaOrigin() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x70): undefined reference to `wxWindowBase::Fit()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x74): undefined reference to `wxWindowBase::FitInside()'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x7c): undefined reference to `wxTopLevelWindowBase::DoSetSizeHints(int, int, int, int, int, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x80): undefined reference to `wxWindowBase::SetVirtualSizeHints(int, int, int, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x84): undefined reference to `wxTopLevelWindowBase::SetMinSize(wxSize const&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x88): undefined reference to `wxTopLevelWindowBase::SetMaxSize(wxSize const&)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x94): undefined reference to `wxWindowBase::DoSetVirtualSize(int, int)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x98): undefined reference to `wxWindowBase::DoGetVirtualSize() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xa0): undefined reference to `wxWindowBase::GetWindowBorderSize() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xa4): undefined reference to `wxTopLevelWindowMSW::Show(bool)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xa8): undefined reference to `wxWindow::Enable(bool)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xb4): undefined reference to `wxWindowBase::IsShownOnScreen() const'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xb8): undefined reference to `wxWindow::SetWindowStyleFlag(long)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xc4): undefined reference to `wxWindow::SetExtraStyle(long)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xc8): undefined reference to `wxWindowBase::MakeModal(bool)'
    [mein Benutzerordner]\LOKALE~1\Temp/cc82qLOB.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0xd4): undefined reference to `wxWindow::SetFocus()'
    
    [...]
    
    collect2: ld returned 1 exit status
    

  • Mod

    Du musst noch die entsprechenden wxLibs hinzulinken.


Anmelden zum Antworten