我写了一个继承自 wxDialog 的类。我目前在 Ubuntu 12.04 上,使用 Code::Blocks 和 gcc 4.6。在我将此类包含在项目中之前,我的应用程序工作正常:调试和发布配置都会给出相同的错误。这是代码:
头文件
#ifndef EBCDIALOG_H
#define EBCDIALOG_H
#include <wx/dialog.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/button.h>
class EBCDialog : public wxDialog
{
public:
EBCDialog(wxWindow* parent, wxWindowID id, const wxString& title );
~EBCDialog();
void OnOK(wxCommandEvent& event);
private:
DECLARE_CLASS(EBCDialog)
DECLARE_EVENT_TABLE()
};
#endif //EBCDIALOG_H
cp文件:
#include "EBCDialog.h"
EBCDialog::EBCDialog(wxWindow* parent, wxWindowID id, const wxString& title ) : wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
// Create text ctrl with minimal size 100x60
topSizer->Add(new wxTextCtrl(this, wxID_ANY, wxT("test"), wxDefaultPosition, wxSize(100,60)),
1, // make vertically stretchable
wxEXPAND| // make horizontally stretchable
wxALL, // and make border all around
10); // set border width to 10
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
buttonSizer->Add(new wxButton(this, wxID_OK, _T("OK")),
0, // make horizontally unstretchable
wxALL, // make border all around: implicit top alignment
10); // set border width to 10
buttonSizer->Add(new wxButton(this, wxID_CANCEL, _T("Cancel")),
0, // make horizontally unstretchable
wxALL, // make border all around (implicit top alignment)
10); // set border width to 10
topSizer->Add(buttonSizer,
0, // make vertically unstretchable
wxALIGN_CENTER ); // no border and centre horizontally
SetSizer( topSizer ); // use the sizer for layout
topSizer->Fit( this );
// fit the dialog to the contents
topSizer->SetSizeHints( this ); // set hints to honor min size
}
EBCDialog::~EBCDialog()
{
}
void EBCDialog::OnOK(wxCommandEvent& event)
{
}
BEGIN_EVENT_TABLE(EBCDialog, wxDialog)
EVT_BUTTON(wxID_OK, EBCDialog::OnOK)
END_EVENT_TABLE()
这是代码::块日志:
g++ -Wall -I/usr/lib/i386-linux-gnu/wx/include/gtk2-unicode-debug-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_ WXDEBUG _ -D_ WXGTK_ -pthread -O2 -I"/home/angelo/CodeBlocks/事件总线配置器/包括"-I"/home/angelo/CodeBlocks/事件总线配置器/位图"-c"/home/angelo/CodeBlocks/事件总线配置器/src/EBCDialog.cpp" -o obj/src/EBCDialog.o g++ -o "bin/事件总线配置器" obj/src/EBCApp.o obj/src/EBCDialog.o obj/src/EBCFrame.o obj/src /EBCList.o obj/src/HandlerFile.o -L/usr/lib/i386-linux-gnu -pthread -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/i386-linux- GNU -lwx_gtk2ud_richtext-2.8 -lwx_gtk2ud_aui-2.8 -lwx_gtk2ud_xrc-2.8 -lwx_gtk2ud_qa-2.8 -lwx_gtk2ud_html-2.8 -lwx_gtk2ud_adv-2.8 -lwx_gtk2ud_core-2.8 -lwx_baseud_xml-2.8 -lwx_baseud_net-2.8 -lwx_baseud-2.8 -s OBJ / SRC / EBCDialog.o :(.rodata._ZTV9EBCDialog[用于 EBCDialog 的 vtable]+0x8):未定义对 `EBCDialog::GetClassInfo() const' 的引用 collect2:ld 返回 1 个退出状态进程以状态 1 终止(0 分 2 秒)1 个错误,0 个警告
任何帮助表示赞赏,谢谢!