Visual Studio 版本:15.8.1
wxWidgets 版本: 3.1.1html
Not Using Precompiled Headers
,關閉stdafx.h
預編譯頭文件$wxWidgetsPath\include
$wxWidgetsPath爲安裝wxWidgets的根目錄路徑$wxWidgetsPath\lib\vc_lib
Step 6. Project -> $app Proterties -> Linker -> Input -> Additional Dependencies
按照實際依賴需求,增長lib文件,本教程添加以下(部分可能爲冗餘lib文件)c++
wxmsw31ud_adv.lib wxmsw31ud_core.lib wxbase31ud.lib wxbase31ud_net.lib wxmsw31ud_html.lib wxbase31ud_xml.lib wxmsw31ud_aui.lib wxmsw31ud_gl.lib wxmsw31ud_media.lib wxmsw31ud_propgrid.lib wxmsw31ud_qa.lib wxmsw31ud_ribbon.lib wxmsw31ud_richtext.lib wxmsw31ud_stc.lib wxmsw31ud_xrc.lib wxscintillad.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib
上述配置能夠選定VS2017配置爲Debug或Release,具體應用Build時候選擇相應的配置模式便可。切記要選擇wxWidgets編譯時候相應的系統位數(32位),即VS2017的x86。64位(x64)暫未成功
配置完畢之後,能夠成功Build或Debug,並看到wxWidgets的Hello World程序。app
成功編譯的截圖:框架
wxWidgets: 官方「Hello World"教程ui
#include <wx/wxprec.h> // 預編譯頭文件 #ifndef WX_PRECOMP #include <wx/wx.h> #endif // 聲明當前應用 class MyApp : public wxApp { public: virtual bool OnInit(); }; // 當前應用的主框架以及事件句柄 class MyFrame : public wxFrame { public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); private: void OnHello(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); wxDECLARE_EVENT_TABLE(); }; // 事件標識符 enum { ID_Hello = 1 }; // 定義事件表 wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Hello, MyFrame::OnHello) EVT_MENU(wxID_EXIT, MyFrame::OnExit) EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) wxEND_EVENT_TABLE() // 應用的入口 wxIMPLEMENT_APP(MyApp); // 應用的Init事件句柄 bool MyApp::OnInit() { MyFrame *frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340)); frame->Show(true); return true; } // 主框架的初始化 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size) { wxMenu *menuFile = new wxMenu; menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item"); menuFile->AppendSeparator(); menuFile->Append(wxID_EXIT); wxMenu *menuHelp = new wxMenu; menuHelp->Append(wxID_ABOUT); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append(menuFile, "&File"); menuBar->Append(menuHelp, "&Help"); SetMenuBar(menuBar); CreateStatusBar(); SetStatusText("Welcome to wxWidgets!"); } // Exit事件句柄 void MyFrame::OnExit(wxCommandEvent& event) { Close(true); } // About事件句柄 void MyFrame::OnAbout(wxCommandEvent& event) { wxMessageBox("This is a wxWidgets' Hello world sample", "About Hello World", wxOK | wxICON_INFORMATION); } // Hello事件句柄 void MyFrame::OnHello(wxCommandEvent& event) { wxLogMessage("Hello world from wxWidgets!"); }