wxWidget-搭建开发环境

vs2019 wxWidget 3.1.3

解压路径是 E:\wxWidgets-3.1.3

设置系统环境变量:$(WXWIN) = E:\wxWidgets-3.1.3

编译

  1. Open a “Visual Studio Command Prompt” window
  2. Change directory to %WXWIN%\build\msw and type nmake /f makefile.vc to build debug static version
    or nmake /f makefile.vc BUILD=release to build release static version
    or nmake /f makefile.vc BUILD=release SHARED=1 release DLL version
    or TARGET_CPU=X64 for 64bit version
  3. to verify your build, change the directory to %WXWIN%\samples\minimal and
    run the same nmake command (with the same parameters there), this
    should create a working minimal wxWidgets sample.
  4. If you need to rebuild, use “clean” target first or “nmake /a”.
    nmake /f makefile.vc clean

新建项目

  1. vs2019 新建空白项目
  2. 添加 include 和 lib 路径
1
2
3
4
5
$(WXWIN)\include\
$(WXWIN)\include\msvc\

$(WXWIN)\lib\vc_lib\mswud
$(WXWIN)\lib\vc_lib
  1. Linker 里面子系统改成 windows
  2. property manager 里面添加 $(WXWIN)\wxwidgets.props
  3. 添加代码

MainApp.h

1
2
3
4
5
6
7
8
9
#include <wx/wx.h>

class MyProjectApp : public wxApp
{
public:
MyProjectApp();
virtual ~MyProjectApp();
virtual bool OnInit() override;
};

MainApp.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "MainApp.h"

#include <wx/wx.h>

MyProjectApp::MyProjectApp()
{
}

MyProjectApp::~MyProjectApp()
{
}

bool MyProjectApp::OnInit()
{
wxFrame* mainFrame = new wxFrame(nullptr, wxID_ANY, L"MyProject");
mainFrame->Show(true);
return true;
}

wxIMPLEMENT_APP(MyProjectApp);
坚持原创技术分享,您的支持将鼓励我继续创作!