Monday, April 3, 2017

How to compile wxWidgets with Visual Studio 2010


wxWidgets is a free, open source and mature a C++ library that lets you to create a cross platform application in Windows, Linux and Mac OS X. For Windows OS, you can install wxWidgets by download the binaries in https://www.wxwidgets.org/downloads/ but recommend that you build wxWidgets from the source by yourself. To start compiling, you need to download the source in here.

In this tutorial, I used Visual Studio 2010 to build the source and It is very easy to compiling the source. Once you downloaded, then open the project with Visual Studio 2010 at C:\wxWidgets-3.1.0\build\msw\wx_vc10.sln, result as following picture below


Pic 1. Open Project wxWidgets Visual Studio 2010

Then select solution configurations to Debug, Release, DLL Debug, DLL Release and build project solution.


Pic 2. Compiling Result in Debug Configuration


Once the compiling process has done, wxWidgets binaries will be created in folder
  C:\wxWidgets-3.1.0\lib\vc_dll
  C:\wxWidgets-3.1.0\lib\vc_lib


Lets try wxWidget by creating a simple project wxHello Project

1. Create new project Win32 Console Application and choose Empty project

2. Add new item Hello.cpp and copy paste code below:


#include "wx/wx.h"

class App: public wxApp {
public:
virtual bool OnInit();
};

class Frame: public wxFrame {
public:
Frame(const wxString& title);
};

Frame::Frame(const wxString& title): wxFrame(NULL, wxID_ANY, title)
{
}

DECLARE_APP(App)
IMPLEMENT_APP(App)

bool App::OnInit() {
Frame *frame = new Frame( _("Hello World") );
frame->Show( true );
return true;
}



3. Configure your project properties
    - In General :
          Character Set : Use Unicode Character Set

    - In C/C++   :
          General: 
                   C:\wxWidgets-3.1.0\include;C:\wxWidgets-3.1.0\include\msvc;
          Preprocessor:  
                 WIN32;_DEBUG;_CONSOLE;__WXMSW__;
                  __WXDEBUG__;_WINDOWS;wxUSE_GUI=1;

   - Linker:
          Additional Library Directories:
                 C:\wxWidgets-3.1.0\lib\vc_lib;

         Additional Dependencies:
                wxbase31ud.lib;wxmsw31ud_core.lib;wxbase31ud_net.lib;
                wxbase31ud_xml.lib;wxmsw31ud_adv.lib;wxmsw31ud_aui.lib;
                wxmsw31ud_gl.lib;wxmsw31ud_html.lib;wxmsw31ud_media.lib;
                wxmsw31ud_propgrid.lib;wxmsw31ud_qa.lib;wxmsw31ud_ribbon.lib;
                wxmsw31ud_richtext.lib;wxmsw31ud_stc.lib;wxmsw31ud_webview.lib;
                wxmsw31ud_xrc.lib;wxjpegd.lib;wxexpatd.lib;wxpngd.lib;wxregexud.lib;
                wxscintillad.lib;wxtiffd.lib;wxzlibd.lib;

   - System:
         SubSystem:
                Windows (/SUBSYSTEM:WINDOWS)


Then compile by pressing Ctrl+F5. If you are successfull then you will get result as picture below



Thank you







No comments:

Post a Comment