wxWidgets zum laufen kriegen



  • Hallo 🙂

    ich versuche gerade meine erste Hello World Application in C++ zu schreiben. Weil ich ein Lehrbuch habe in dem sehr viel über wxWidgets steht habe ich mich dazu entschieden, erst einmal mit diesem zu arbeiten.

    Ich scheitere allerdings schon relativ früh. Ich kriege die wxWidgets einfach nicht zum laufen. Ich arbeite hier leider mit Windows 7 und kann das auch nicht ändern.

    Meine bisherigen Versuche sehen wie folgt aus:
    Unter cygwin/include/wx die h Dateien hinkopiert. Hat zur Folge dass Netbeans Sachen wie

    #include <wx/wx.h>
    

    erkennt.

    Beim Code selber erkennt er die wxApp Klasse aber nicht und unterstreicht mir diese Rot und kann deswegen auch nicht kompilieren.

    // base.h
    #ifndef BASIC_H
    #define BASIC_H
    
    class HalloWeltApp : public wxApp {
    public:
    	virtual bool OnInit();
    };
    
    class BasicFrame : public wxFrame {
    public:
    	BasicFrame ( const wxChar *title, int xpos, int ypos, int width, int height);
    	~BasicFrame();
    };
    #endif
    
    #include <wx/wx.h>
    #include "base.h"
    IMPLEMENT_APP(HalloWeltApp)
    
        bool HalloWeltApp::OnInit() {
            BasicFrame *frame=new BasicFrame( wxT("Hallo Welt"),50,50,450,300);
            frame->Show(TRUE);
            SetTopWindow(frame);
            return TRUE;
        }
        BasicFrame::BasicFrame (const wxChar *title,int xpos, int ypos, int width,
                int height) : wxFrame((wxFrame *) NULL, -1, title, wxPoint(
        xpos,ypos), wxSize(width,height)){}
    
        BasicFrame::~BasicFrame(){}
    

    Wie gesagt unterstreicht er mir dort was wxApp in der base.h Datei.

    Ich habe dann als weitere Option dieses Tutorial verfolgt. Ich habe mir MinGW und erneut das wxWidgets Paket heruntergeladen und das Tutorial verfolgt. Hier kriege ich allerdings an Punkt 8 in der Konsole eine Fehlermeldung.

    Ich habe mir auch das wxPack_v2.8.11.03 heruntergeladen und es mit Visual Studio C++ 2010 Express soweit dazu gebracht, dass er die includes erkennt, beim kompilieren aber einen Fehler auswirft, der gute 100 Zeilen lang ist. Hier mal der Anfang des Fehlers:

    1>------ Erstellen gestartet: Projekt: GUI, Konfiguration: Debug Win32 ------
    1>base.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl wxAppConsole::CheckBuildOptions(char const *,char const *)" (?CheckBuildOptions@wxAppConsole@@SA_NPBD0@Z)" in Funktion ""class wxAppConsole * __cdecl wxCreateApp(void)" (?wxCreateApp@@YAPAVwxAppConsole@@XZ)".
    1>base.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall wxApp::wxApp(void)" (??0wxApp@@QAE@XZ)" in Funktion ""public: __thiscall HalloWeltApp::HalloWeltApp(void)" (??0HalloWeltApp@@QAE@XZ)".
    1>base.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual class wxClassInfo * __thiscall wxApp::GetClassInfo(void)const " (?GetClassInfo@wxApp@@UBEPAVwxClassInfo@@XZ)".
    1>base.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""protected: virtual class wxObjectRefData * __thiscall wxObject::CreateRefData(void)const " (?CreateRefData@wxObject@@MBEPAVwxObjectRefData@@XZ)".
    1>base.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""protected: virtual class wxObjectRefData * __thiscall wxObject::CloneRefData(class wxObjectRefData const *)const " (?CloneRefData@wxObject@@MBEPAVwxObjectRefData@@PBV2@@Z)".
    1>base.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual bool __thiscall wxEvtHandler::ProcessEvent(class wxEvent &)" (?ProcessEvent@wxEvtHandler@@UAE_NAAVwxEvent@@@Z)".
    

    Das Codebeispiel weiter oben (base.h und base.cpp) habe ich aus dem erwähnten Buch.

    Langsam verliere ich den Glauben daran, dass ich die wxWidgets auf meinem Pc zum laufen kriege.

    Vielen Dank im voraus 🙂



  • wxWidgets 2.8 geht unter MSVC10 leider nicht. Aber du kannst wxWidgets 2.9.1 verwenden (was ich sowieso eher empfehlen wuerde...). Zwar wird immernoch kein MSVC10-Project mitgeliefert, aber das kann man sich zusaetzlich downloaden.
    Hier ist ne kleine Anleitung: http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide#Visual_Studio_C.2B.2B_2010

    Note: at time of writing (25/09/2010), for building wxWidgets with VC++ 2010, it is recommended to carry out the 3 following simple steps:

    1. Download and execute the 2.9.1 .exe installer.
    2. Download wx291_msw_vc10.zip from this page.
    1. Unzip it in the "build" directory.
    3. In build/wx291_msw_vc10, open wx_vc10.sln, select a configuration (for example "DLL Release") and hit F7 until all 22 projects are built successfully (see below screenshot).

    Das hat bei mir (Windows 7, MSVC10 Express, wxWidgets 2.9.1) prima geklappt.

    Wenn du unbedingt die Stable verwenden moechtest, dann musst du dir wohl MSVC9 installieren... Das waere uebrigens auch die einfachste - "idiotensicherste" - Variante. Du musst nur wxWidgets 2.8.11 (den Source Code) downloaden und dann die MSVC9-Project-Datei oeffnen - dann F7 und er muesste alles taddelos kompilieren.


Anmelden zum Antworten