Configure code on Windows: blocks + wxWidgets + (wxsmith | wxformbuilder)

Source: Internet
Author: User
Tags wxwidgets

 

Part of this article is transferred from the Network (original link: http://shiningray.cn/windows-shang-pei-zhi-codeblocks-wxwidgets.html), and on the basis of the original simplified description, expand the content to adapt to the current software version, and records my doubts and answers in the operation process, to help more cainiao like me ~

 

Please first read this article to learn about the operation context before proceeding with the practice.

 

Introduction to mingw32

A set of GNU-compliant compilers and debuger tools, which are free and open-source and used to replace Microsoft's VC ++ series compilers and debuggers.

Code: blocks:

A cross-platform C ++ ide that supports windows, Linux, and MacOSX. It also supports various compilers, such as GNU/mingw C/C ++, VC ++ 6.0/2003/2005/2008, Borland C ++, and digital Mars.

 

The latest version is 10.05,

Official Website: http://www.codeblocks.org /,

Download the http://www.codeblocks.org/downloads/26 page (download codeblocks-10.05mingw-setup.exe version ,)

I uploaded a configuration that can be directly used and divided into three parts:

Http://download.csdn.net/source/2725048

Http://download.csdn.net/source/2725067

Http://download.csdn.net/source/2725128

WxWidgets:

It is a very good cross-platform GUI framework. c ++ applications compiled by it can be easily migrated to different systems.

Configuration code: blocks (skip this step if you download the provided mod) The latest code: Blocks

Download the latest 10.05.

WxWidgets

You can download the source code of wxWidgets and build it by yourself, or directly install the pre-compiled wxpack.

WxWidgets source code

As mentioned above, there are two options:

The installation package is small and can be customized as needed, but it takes a long time to compile. If you do not know the compilation options, you may fail to configure code: blocks.

Currently, the recommended wxWidgets version is 2.8.7. Click here to download the wxWidgets 2.8.7 source code Windows Installation Package (wxmsw-2.8.7-setup.exe; 12.0 MB ). You can also check the wxWidgets download page to see if there is any updated stable version download.We strongly recommend that you install the code in a path without spaces.Ensure that the disk has at least MB of free space.

Wxpack

Although the installation package is up to 200 MB, it requires 3 GB for all installation, but it contains all the library files that may be used in pre-compilation, and contains two versions of VC and GCC, you don't have to consider the build options.

The current stable release version of wxpack is v2.8.7.03 Based on wxWidgets 2.8.7. Click here to download wxpack v2.8.7.03 (wxpack_v2.8.7.03.exe, 236.9 MB ). You can also view the wxpack download page to see if there is any updated stable version download.We strongly recommend that you install wxpack in a path without spaces.If you select msvc only, ensure that at least MB of space is available. If you only select mingw/GCC, ensure that at least GB of space is available.

Prompt

If the disk uses the NTFS format, you can enable the File compression function. The preceding directory can reduce the space usage by 50% after compression.

Compile wxWidgets

You can skip this step by using wxpack.


Go to the wxWidgets build directory, where <wxWidgets> is the source code path. The default value isC:/wxWidgets-2.8.7:

cd <wxWidgets>/build/msw

Execute the build command,

Mingw/GCCThe recommended command is:

mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1

MsvcThe recommended build command is:

nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1

This process takes a long time. A fast machine can be completed in about 30 minutes. It may take several hours to slow down.

If the GCC version used is newer, a large number of warnings may occur during the build process. This will obviously cause the building process to slow down; you can redirect the error information to the file and add2> err.log, You can also use2>nulDirectly disable warning information.

For more information about build, shared, monolithic, and Unicode options, see the description of wxWidgets building parameters. These parameters are critical, they directly define the basic wxWidgets development environment you are using. You must set the code: blocks Configuration Wizard strictly according to your compilation parameters.

Create a wxWidgets project in code: Blocks

On the code: blocks start page, select "Create a new project", or select "new"-> "project…" from the File menu ...".

Find and select "wxWidgets project" and create the project. A wizard is displayed to help configure the wxWidgets project:

  1. The first page is the introduction. You can skip it later.
  2. Select the wxWidgets version you want to use. If you configure it according to the process described in this article, you should select "wxWidgets 2.8.x ".
  3. Set the location of your project name.
  4. Enter the author's information (not required)
  5. Select Automatic Code and file generation options.
  6. Select the location of wxWidgets. We strongly recommend that you use global variables here: Enter "$ (# wx)" (excluding quotation marks ). If you have not defined this global variable, the global variable dialog box appears. In the base path, select your wxWidgets installation path. Other paths are optional.
  7. Select debug/release configuration for your project. We recommend that you select at least debug configuration.
  8. Select your wxWidgets build option. It must be consistent with the option used when you build wxWidgets! If you have constructed it in the previous method, you should select all three options under "wxWidgets library Settings. If wxpack is used, because wxpack contains different versions, you only need to select the options you need. Another setting on this page has nothing to do with the wxWidgets build options. You can choose one as you like. If, for some reason, you want to use the wxWidgets build of the debug version, select "Configure advanced options" and then select "use _ wxdebug _ and debug wxWidgets lib" on the next page ".
  9. Select an additional library if needed. Generally, you do not need to select either of them.
Build and run the program

Next, you can select "build and run" (F9) to build and run the program. If it succeeds, your wxWidgets application will appear. If any problem occurs, you can refer to the following Frequently asked questions.

 

Visual Interface editing

In code: blocks, you can use wxsmith or wxformbuilder to edit the interface. wxsmith has been integrated in the Code: Blocks provided by me. Just select it in the corresponding steps of the wxwidget creation wizard. after the project is created, open others-> wxsmith-> XXXX in the file tree. WXS, code: blocks will be automatically opened with wxsmith for editing.

 

As for wxformbuilder, it is not as convenient as wxsmith but runs independently as a program. However, the configuration method is also provided here:

In the wxwidget creation wizard, select wxformbuilder as needed. after creating a project, go to Settings> environment> files extension handling and select * under registered wildcards *. FBP. If no, create one through new. Select launch an external program on the right and then select your wxformbuilder.exe path. click OK to complete the configuration.

Find others> wxsmith> XXXX under the file tree. FBP, double-click it, code: blockswill automatically open wxformbuilder.exe for editing. if you want to use wxwidget skillfully, you also need to understand the principles of wxwidget and javax. the swing control is very similar. I will not explain it here. If you need it, please google it ~

WxWidgets compilation option overview build

Build control wxWidgets build debugging version (build = Debug) or release version (build = release ). In most cases, you only need to release wxWidgets, because you should not want to debug wxWidgets itself, at the same time, you can still build the debugging version of your own program by linking to the release version of wxWidgets.

  • DebuggingBuilding wxWidgets will create a library with the suffix "D", such as "libwxmsw28d. A" and "wxmsw28d_gcc_custom.dll ".
  • DebuggingWhen wxWidgets is built, the "mswd" or "mswud" Directory will be created in the output directory of the wxWidgets library.
  • ReleaseThe library created by building wxWidgets does not have the "D" suffix, for example, "libwxmsw28.a" and "wxmsw28_gcc_custom.dll ".
  • ReleaseWhen wxWidgets is built, the "MSW" or "mswu" directory is created in the output directory of the wxWidgets library.
Shared

Shared controls whether wxWidgets constructs a DLL (shared = 1) or a static library (shared = 0 ). Using the constructed DLL, the main program can be built quickly, and the executable files are smaller. However, the total size of the executable file with wxWidgets DLL is larger, but the same dll can be used for different executable files.

  • WxWidgetsDLLThe build will create a imported Library (such as libwxmsw28.a) and a DLL file (such as wxmsw28_gcc_custom.dll ). You must include this DLL when releasing your program.
  • WxWidgetsStaticThe build only creates a static library (such as libwxmsw28.a), and does not need to include wxWidgets DLL during release.
Monolithic

Monolithic controls whether to build a single library (monolithic = 1) or Multiple Component Libraries (monolithic = 0 ). Using a single build method makes it easier to set up and develop a project. If you use a DLL to build a project at the same time, you only need to distribute a DLL file. If you use a non-single build (multilib), multiple different libraries will be built. At the same time, you can avoid linking the basic wxWidgets code to the main program to remove unnecessary libraries. Make sure that you have selected the correct component library.

  • WxWidgetsSingleOnly one wxWidgets import library (such as libwxmsw28.a) and one DLL (such as wxmsw28_gcc_custom.dll) will be created for the build ).
  • WxWidgetsMultiple databases(Multilib) the build creates multiple import/export libraries (libwx28_base.a) and multiple DLL files.
  • Any wxWidgets build will create additionalStaticLibrary (such as libwxexpat. A and libwxjpeg. ). These libraries are generally not required for wxWidgets DLL build, but are required when static build is used.
Unicode

Unicode controls wxWidgets and whether your program uses a wide string that supports Unicode. Most applications on Windows 2000 or higher should support Unicode. Earlier Windows versions do not necessarily support Unicode. You should always use wxWidgets_("string")And_T("string")Macro to ensure that hard-coded strings are of the correct type during compilation.

  • WxWidgetsUnicode(UNICODE = 1) the build will create a library with the "U" suffix, such as "libwxmsw28u. A" and "wxmsw28u_gcc_custom.dll ".
  • WxWidgetsUnicodeThe "mswu" or "mswud" Directory will be created in the output directory of the wxWidgets library.
  • WxWidgetsANSI(UNICODE = 0) The created library does not have the "U" suffix, for example, "libwxmsw28.a" or "wxmsw28_gcc_custom.dll ".
  • WxWidgetsANSIThe "MSW" or "mswd" Directory will be created in the output directory of the wxWidgets library.
A common error similar to "wx/setup. h: no such file or directory" occurs.

You lack an important compiler search path in the build options. First, check whether you have correctly selected the wxWidgets build configuration when running the wxWidgets Project Wizard. If you re-run the wizard and the configuration is still invalid, open the build option of your project and add it to the compiled search path"$(#wx.lib)/gcc_dll/mswu"(This is assumed to be a single Unicode DLL build ).

Error similar to "cannot find-lwxmsw28u"

The Link Library in the build option is incorrect. First, check whether you have correctly selected the wxWidgets build configuration when running the wxWidgets Project Wizard. If the Wizard is re-run and the configuration is still invalid, determine the database you have built and adjust the database name in the build options accordingly.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.