wxWidgets
Code::BlocksEnvironment
Code::Blocks download:
Code::Blocks uses:
codeblocks-16.01mingw-setup.exe
Its gcc version is 4.9.2, also change it in settings
## wxMSW-3.1.0_gcc492 download: ##
Code::Blocks configuration:
Unzip wxMSW-3.1.0_gcc492TDM_Dev.7z and wxWidgets-3.1.0-headers.7z to the same directory: X:\wxMSW-3.1.0_gcc492TDM
Add a wxWidgets root directory environment variable to the environment variable, the new user variable is named wxwin, and the value is X:\wxMSW-3.1.0_gcc492TDM
Open Code::Blocks, select the menu Settings->Global Variables..., create a new wx variable under the default setting, and under Build-in fields:, fill in " wxwin" in the base (wxwin is a variable that was just set) , fill in "{wxwin}" in include (wxwin is a variable set just now), and fill in "{wxwin}" in includew x win " ( w x win is a variable just set ) , fill in " { wxwin }\include" in i n c l u d e , and fill in " ${ wxwin}\lib"
New Project:
create project
The process of building a project
Through the menu "File" -> "New" -> "Project...", select "Empty project" to create a project.
Click the menu File->New->File... to create a new source program file for the project, main.cpp:
#include <wx/wx.h>
class Simple : public wxFrame
{
public:
Simple(const wxString & title);
};
Simple::Simple(const wxString & title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
Centre();
}
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
Simple * simple = new Simple(wxT("Simple"));
simple->Show(true);
return true;
}
Select the menu Project->Build options..., in the tab Search directories, set the Compiler. Add the directories X:\wxMSW-3.1.0_gcc492TDM\include and X:\wxMSW-3.1.0_gcc492TDM\lib\gcc_dll\mswad through "Add", it is best to include mswud on the top and bottom. (use mswud for debug version and mswu for release version)
Select the menu Project->Build options..., in the tab Linker settings, you need to add the "target file" to be connected. As shown in the figure, add all the .a files in the X:\wxMSW-3.1.0_gcc492TDM\lib\gcc_dll folder through the Add button
At this point, the compilation can pass.
Build using the Code::Blocks wizard
Use the wizard to build a "wxWidgets project" project.
-
GUI design tools and program types, with wxSmith and Dialog based. If "Code::Blocks configuration" is set, wxWidgets'location can be directly filled in "$(#wx)", otherwise set to X:\wxMSW-3.1.0_gcc492TDM directory.
-
wxWidgets Library Settings选择Enable unicode
-
Select Configure Advanced Options
-
选择Use _WXDEBUG_ and Debug wxWidgets lib
-
Select GUI Mode Application
Generated program source code:
The program runs:
Some dlls are needed when the program is running, look for it in wxMSW-3.1.0_gcc492TDM_ReleaseDLL.7z, put it in the program directory to start.
VS2010 environment
wxMSW-3.1.0_vc100 download:
project
Extract wxMSW-3.1.0_vc100_Dev.7z and wxWidgets-3.1.0-headers.7z to X:\wxMSW-3.1.0_vc100_Dev
New win32 project windows application empty project
Additional include directories
- X:\wxMSW-3.1.0_vc100_Dev\include
- X: \ wxMSW-3.1.0_vc100_Dev \ lib \ vc_lib \ mswud (debug)
- X:\wxMSW-3.1.0_vc100_Dev\lib\vc_lib\mswu(release)
Add additional dependencies:
wxbase31ud_net.lib
wxmsw31ud_html.lib
wxbase31ud_xml.lib
wxmsw31ud_adv.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
wxmsw31ud_core.lib
wxbase31ud.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxexpatd.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
head File:
#include <wx/wx.h>
class wxMyApp:public wxApp
{
public:
virtual bool OnInit();
};
class wxMyFrame:public wxFrame
{
public:
wxMyFrame(const wxString& title);
};
Source File:
#include "头文件.h"
bool wxMyApp::OnInit()
{
wxMyFrame *pMyFrame=new wxMyFrame(_("myframe"));
pMyFrame->Show(TRUE);
return TRUE;
}
wxMyFrame::wxMyFrame(const wxString& title):wxFrame(NULL,NULL,title)
{
}
DECLARE_APP(wxMyApp);
IMPLEMENT_APP(wxMyApp);