vererbung aus dll in exe
-
hallo,
ich habe ein problem bei der vererbung, wobei die basisklasse in einer dll und die abgeleitete in meiner exe steht.
in der app habe ich folgendes:
#include "basedll.h" class testClass : public libconfig::testBase { public: testClass(wxWindow *parent) : libconfig::testBase(parent){}; };
basedll.h:
namespace libconfig { class __declspec(dllexport) testBase : public wxPanel { public: testBase( wxWindow* par ){}; }; }
wenn ich den ctor aus basedll.h in basedll.cpp (inkl. using namespace libconfig;) auslagere, dann kommt folgender fehler, sonst nicht:
> libConfig.dll!wxWinHashTable::Get(long key=1378044) Zeile 596 + 0x17 Bytes C++ libConfig.dll!wxFindWinFromHandle(void * hWnd=0x001506fc) Zeile 3434 C++ libConfig.dll!wxAssociateWinWithHandle(HWND__ * hWnd=0x001506fc, wxWindow * win=0x027fb468) Zeile 3443 + 0x9 Bytes C++ libConfig.dll!wxWindow::SubclassWin(void * hWnd=0x001506fc) Zeile 1146 + 0xd Bytes C++ libConfig.dll!wxWindow::MSWCreate(const wchar_t * wclass=0x103b5060, const wchar_t * title=0x00000000, const wxPoint & pos={...}, const wxSize & size={...}, unsigned long style=1375731712, unsigned long extendedStyle=65536) Zeile 3616 C++ libConfig.dll!wxWindow::Create(wxWindow * parent=0x027fae00, int id=-1, const wxPoint & pos={...}, const wxSize & size={...}, long style=2621440, const wxString & name={...}) Zeile 612 + 0x21 Bytes C++ libConfig.dll!wxPanel::Create(wxWindow * parent=0x027fae00, int id=-1, const wxPoint & pos={...}, const wxSize & size={...}, long style=2621440, const wxString & name={...}) Zeile 117 + 0x20 Bytes C++ libConfig.dll!wxPanel::wxPanel(wxWindow * parent=0x027fae00, int winid=-1, const wxPoint & pos={...}, const wxSize & size={...}, long style=2621440, const wxString & name={...}) Zeile 58 C++ libConfig.dll!libconfig::testBase::testBase(wxWindow * par=0x027fae00) Zeile 281 + 0x7d Bytes C++ myapp.exe!testClass::testClass(wxWindow * parent=0x027fae00) Zeile 41 + 0x13 Bytes C++
wie kann ich den inhalt des ctor in der .cpp lassen und trotzdem in der exe aus der dll erben?
danke!
-
Sollte im Konstruktor von testBase nicht auch das wxPanel initialisiert werden?
Wird in deinem Beispiel zumindest nicht getan ...
-
ja, du hast recht, war ein copy-paste-fehler von mir. das problem bleibt dasselbe:
das funktioniert nicht:
basedll.h:class __declspec(dllexport) testBase : public wxPanel { public: testBase( wxWindow* par ); };
und basedll.cpp:
#include "basedll.h" testBase::testBase( wxWindow* par ) : wxPanel(par){}
aber das hier funktioniert:
basedll.h:class __declspec(dllexport) testBase : public wxPanel { public: testBase( wxWindow* par ) : wxPanel(par){}; };
-
es bleibt mir also nichts anderes übrig, als immer den kompletten ctor in die header datei zu schreiben? in meinem realen projekt zieht das wieder andere probleme nach sich, weil der code auch includes benötigt.
kann doch nicht sein, oder?