Basic wxWidgets GUI Unicode application with MingGW

Basic wxWidgets GUI Unicode application with MingGW
Development Environment:
  • Windows 8.1, 10
  • Code::Blocks v13.12 - v16.01 with MingGW Setup
  • wxWidgets v3.0.3, v3.0.4

< Why MingGW and wxWidgets? >
MingGW itself is bound by the terms and conditions of any GNU GPL license but products (applications) resulting from it are allowed for commercial purposes too.

wxWidgets also allows commercial uses of the products built with it. And furthermore, MingGW and wxWidgets come by free of charge , so that those who have great zeal for programming but cannot afford a commercial one could delve into programming right away.

Finally, both of them support multi-platforms!


< Code::Blocks and Project Settings for wxWidgets >
  1. Run Code::Blocks :
    A Compiler auto detection dialog box appears >> Select GNU GCC Compiler >> Click [Set as default] >> [OK] :

  2. Choose [File] >> [New] >> [Project] >> [wxWidgets Project] >> [Go].
    A Guide dialog box appears : [Next] >> [wxWidgets 3.0.x].

    Project title : Lukit <<-- User-preferred project name here.
    Folder to create project in : Browse for folders then create and select appropriate one for the project. Then the rest fields are filled out automatically :

    Fill out the author information if seen fit in the Project Details dialog box.
    [Next]

  3. Preferred GUI Builder : None.
    Application Type : Frame Based.
    [Next] >> Specify wxWidgets location :$(WX_MGW)

    [Next] >> Global Variable Editor appears :
    For Built-in fields:

    • base : $(WX_MGW)
    • include : $(WX_MGW)\include
    • lib : $(WX_MGW)\lib


    [Close]

  4. Compiler and build configuration >> [Next] with default values. Nothing to edit here :

  5. In the Various Configuration :
    • Check >> Enabled unicode.
    • Check >> Create and use precompiled header(PCH).
    • Check >> Configure Advanced Options.

    [Next]

  6. Advanced Options :
    • Check >> Use __WXDEBUG__ and Debug wxWidgets lib.
    • Check >> GUI Mode Application for both of the Debug and Release Target fields.

    [Next]

  7. Select additional libraries desired :

    [Finish]

  8. Additional settings should be set before delving into writing code :
    [Project] >> [Build Options...]
    Click on the project name on the left pane :
    Click [Compiler settings] tab
    1. Click [Other compiler options] tab >>
      -pipe
      -mthreads
      -Winvalid-pch
      -include wx_pch.h
      Add : -std=gnu++11 or some other appropriate one.

    2. Click [#defines] tab >>
      • Lukit :
        The following would be already there. If not, add any missing one :
        __GNUWIN32__
        __WXMSW__
        wxUSE_UNICODE
        WX_PRECOMP

        Additionally, add the following :
        wxUSE_GUI=1

      • Debug :
        __WXDEBUG__

      • Release :
        wxDEBUG_LEVEL=0

    Click [Linker settings] tab and make sure <Link libraries> settings are similar to the following configurations respectively for each one :

    • Lukit :

    • Debug :

    • Release :


    Click [Search directories] and check if they are set as follows :

    • [Compiler] tab :
      • Lukit :

      • Debug :

      • Release :

    • [Linker] tab :
      • Both Debug, and Release configuration are as follows :


    [Resource Compiler] settings may well be the same as that of [Compiler]'s.

[OK]
[File] >> [Save Everything]

Done project settings configuration!


< Writing Code for wxWidgets Project >
  • Basic code for skeleton window is already there :


    [Build] menu >> [Build] menu item >> The project will be built without errors.


    [Build] menu >> [Run] menu item >> The project will be run as follows :

      


    Now try building it for release and compare the size of the two versions of the project's executable files.


EOD

No comments:

Post a Comment