单片机搭建环境烧录方法_vs2019搭建wxWidgets环境的配置方法

1.下载

官网:https://www.wxwidgets.org/downloads/

079b939b83d7f45bbb5b28ae7859b0f9.png

下载zip文件即可,也可以下载右边的官方文档。解压路径不要有空格和中文!!!我的解压路径是(D:\wxWidgets-3.1.4)

2.添加环境变量

50b75598f012f5eecc01641d80a51691.png

在系统变量里面添加:变量名:WXWIN  值:D:\wxWidgets-3.1.4(就是你的解压路径,文件夹的绝对路径)

3.编译源码

找到这个路径:D:\wxWidgets-3.1.4\build\msw下的 wx_vc16.sln,用vs2019打开。

官方文档中列出的 VC 与 MSVS 对应关系:

VC++ 7, 8, 9, 10, 11, 12, 14, 15 and 16 ( MSVS 2003, 2005, 2008, 2010, 2012, 2013, 2015, 2017 and 2019)

选择Debug,x64,配置类型选择静态库!然后生成解决方案。这样就在D:\wxWidgets-3.1.4\lib路径下生成了vc_x64_lib文件夹。

63884b23bf250dec713f7475298fe116.png

4.项目配置

创建一个空项目,编辑工程属性,须在【项目属性页】做如下修改:

配置属性 - C/C++ - 常规 - 附加包含目录:添加 $(WXWIN)\include\msvc 和 $(WXWIN)\include

配置属性 - C/C++ - 预处理器 - 预处理器定义:添加 WXMSWUNICODE、NDEBUG,这里若不加UNICODE,则需要在 配置属性 - 高级 - 高级属性 - 字符集 选择【使用 Unicode 字符集】

配置属性 - 链接器 - 常规 - 附加库目录:添加 $(WXWIN)\lib\vc_x64_lib

配置属性 - 链接器 - 系统 - 子系统:选择【窗口】(默认为【控制台】)

5.测试

官方hello word测试案例:

#include "wx\wxprec.h"#include "wx\wx.h"#include #include  using namespace std; #ifndef WX_PRECOMP#include "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);// main function this macro is the main function// create an application instance and starts the program  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",        "Hello string show 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!");} void MyFrame::OnExit(wxCommandEvent& event){    Close(true);} void MyFrame::OnAbout(wxCommandEvent& event){    wxMessageBox("This is a wxWidgets' Hello World sample", "About Hello World", wxOK | wxICON_INFORMATION);} void MyFrame::OnHello(wxCommandEvent& event){    wxLogMessage("Hello world from wxWidgets!");}
6.运行结果

70f309a501b77aad0feedf19e3e3afc4.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值