[Compilation] probleme de linking avec une classe
Bonjour,
J’ai crée un fichier qui utilise plusieurs classes.
Dans l’header “mathplot.h” je déclare la classe mpWindow comme ceci :
wxScrollWindow est une classe issue de wxWidgets.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Class WXDLLEXPORT mpWindow;
class WXDLLEXPORT mpWindow : public wxScrolledWindow
{
public:
mpWindow() {}
mpWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
int flags = 0);
~mpWindow();
wxMenu* GetPopupMenu() { return &m_popmenu; }
.}; |
Dans un autre fichier .cpp, j’utilise le constructeur mpWindow à la ligne 29.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 0)#include «mathplot.h»
..
MyFrame::MyFrame()
: wxFrame( (wxFrame *)NULL, -1, wxT("wxWindows mathplot sample Comparison of Integer Coding Algorithms"))
{
wxMenu *file_menu = new wxMenu();
wxMenu *view_menu = new wxMenu();
file_menu->Append( ID_ABOUT, wxT("&About.."));
file_menu->Append( ID_QUIT, wxT("E&xit\tAlt-X"));
view_menu->Append( mpID_FIT,wxT("&Fit bounding box"), wxT("Set plot view to show all items"));
view_menu->Append( mpID_ZOOM_IN, wxT("Zoom in"), wxT("Zoom 14 in plot view."));
view_menu->Append( mpID_ZOOM_OUT, wxT("Zoom out"), wxT("Zoom 16 out plot view."));
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append(file_menu, wxT("&File"));
menu_bar->Append(view_menu, wxT("&View"));
SetMenuBar( menu_bar );
mpLayer *e, *f, *h, *bs;
wxPoint Lepoint=wxPoint(0,0);
wxSize Lataille=wxSize(100,100);
m_plot = new mpWindow( this, -1,Lepoint ,Lataille, wxSUNKEN_BORDER )
;
} |
Quand je compile, il n’y a aucun probleme de code. Par contre, il y a une erreur de link :
hhh.obj : error LNK2019: symbole externe non résolu "public: __thiscall mpWindow::mpWindow(class wxWindow *,int,class wxPoint const &,class wxSize const &,int)" (??0mpWindow@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@H@Z) référencé dans la fonction "public: __thiscall MyFrame::MyFrame(void)" (??0MyFrame@@QAE@XZ)
1>C:\Users\Pierre\Favorites\Documents\Visual Studio 2008\Projects\Graphs\Debug\Graphs.exe : fatal error LNK1120: 1 externes non résolus
Pourtant, la fonction mpWindow est bien déclarée dans le fichier header et ce header est bien déclaré dans le fichier cpp.
Est-ce parce que j’appelle mal ma fonction ?
Je vois pas du tout ou est le pb.
Merci