我試圖建立一個最小的wxWidgets應用程序,儘可能小的尺寸是很容易的。 (對我來說很簡單,就是這樣)。wxWidgets編譯錯誤(致命錯誤LNK1120:26無法解析的外部)
這是一個Hello World GUI程序,它不會執行任何其他操作。所以,就我所知,我只需要使用Visual C++ 2008 Express Edition在/ MT模式下構建的wxBase和wxCore。
我的應用程序是這樣的:
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/msgdlg.h"
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
enum
{
ID_Quit = 1,
ID_About,
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_("Hello World"), wxPoint(50, 50),
wxSize(450,340));
frame->Show(true);
SetTopWindow(frame);
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_About, _("&About..."));
menuFile->AppendSeparator();
menuFile->Append(ID_Quit, _("E&xit"));
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _("&File"));
SetMenuBar(menuBar);
CreateStatusBar();
SetStatusText(_("Welcome to wxWidgets!"));
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(_("This is a wxWidgets Hello world sample"),
_("About Hello World"),
wxOK | wxICON_INFORMATION, this);
}
它在wxWidgets documentation的Hello World程序的近完全相同的副本。我只是改變了包含文件。順便說一句,用#include "wx/wx.h"
代替它們也不能解決問題。
構建錯誤,我得到的是:
test.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxApp::Initialize(int &,wchar_t * *)" ([email protected]@@[email protected])
test.obj : error LNK2001: unresolved external symbol "protected: void __thiscall wxStringBase::InitWith(wchar_t const *,unsigned int,unsigned int)" ([email protected]@@[email protected])
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxEmptyString" ([email protected]@3PB_WB)
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxStatusLineNameStr" ([email protected]@3QB_WB)
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxFrameNameStr" ([email protected]@3QB_WB)
C:\Users\microsoft\Documents\Visual Studio 2008\Projects\wxAnother\Release\wxAnother.exe : fatal error LNK1120: 5 unresolved externals
我要包括我對項目的屬性所做的所有更改,但我注意到,所有這些錯誤有事情做與wchar_t
,這可能是足以讓某人告訴我是什麼導致了錯誤。
什麼原因導致這些煩人的未解決的外部錯誤,我該如何解決問題(擺脫它們)?
罪魁禍首是Unicode的設置。我已經編譯wxWdigets而不使用Unicode,但我的應用程序的設置具有Unicode。更改了項目中的設置,並解決了問題。謝謝! – 2013-03-12 11:23:10