簡単にできる限り小さいサイズの最小限の wxWidgets アプリケーションを構築しようとしています。(私にとっては簡単です)。
これは、他に何もしない 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 のドキュメントにある Hello World プログラムのほぼ正確なコピーです。インクルードファイルを変更しただけです。ちなみに、それらを交換して#include "wx/wx.h"
も問題は解決しません。
私が得るビルドエラーは次のとおりです。
test.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxApp::Initialize(int &,wchar_t * *)" (?Initialize@wxApp@@UAE_NAAHPAPA_W@Z)
test.obj : error LNK2001: unresolved external symbol "protected: void __thiscall wxStringBase::InitWith(wchar_t const *,unsigned int,unsigned int)" (?InitWith@wxStringBase@@IAEXPB_WII@Z)
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxEmptyString" (?wxEmptyString@@3PB_WB)
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxStatusLineNameStr" (?wxStatusLineNameStr@@3QB_WB)
test.obj : error LNK2001: unresolved external symbol "wchar_t const * const wxFrameNameStr" (?wxFrameNameStr@@3QB_WB)
C:\Users\microsoft\Documents\Visual Studio 2008\Projects\wxAnother\Release\wxAnother.exe : fatal error LNK1120: 5 unresolved externals
プロジェクトのプロパティに加えたすべての変更を含めるつもりでしたが、これらすべてのエラーがwchar_t
.
これらの厄介な未解決の外部エラーの原因と、問題を解決する方法 (それらを取り除く方法) は?