Build the wxWidgets development environment under VC ++ 6.0
Like GTK, QT, SWT, and swing, wxWidgets is also an open-source cross-platform GUI framework.
Because wxWidgets and MFC have some similarities and closeness, You need to experience wxWidgets.
The latest version is 2.8.8. WxWidgets can also run on Windows CE and Palm OS.
Including not only the GUI, but also the media, socket, ODBC and other libraries.
For more information, see wxWidgets's official website: http://www.wxwidgets.org
This article describes how to build the wxWidgets development environment in VC ++ 6.0, including compiling the wxWidgets source code and configuring the VC environment.
The wxWidgets version is 2.8.8.
Step 1: download and install wxWidgets
Download the wxWidgets source code in the http://www.wxwidgets.org/downloads.
You can download Windows Installation edition http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8-Setup.exe (11.9 m)
Or zip compressed http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip (15.9 m)
If we download a wxMSW-2.8.8-Setup.exe, we can run it,
In the process, we assume that the selected installation directory is C:/program files/wxWidgets-2.8.8.
After the installation is complete, we can see that the size of the installation directory is not 127 MB.
Step 2: Compile wxWidgets
There are two compilation methods,
One is to use nmake to compile in the command line.
One is to open wx. DSW in VC ++ for compilation,
1) nmake Compilation
Run cmd.exe to go to the command line, enter the Directory D:/wxWidgets-2.8.8, and then execute
D:/wxWidgets-2.8.8> nmake-F makefile. VC
By default, the static library is compiled into the debug version.
If you want to generate a dynamic library or a release version, you can modify the D:/wxWidgets-2.8.8/build/MSW/config. VC file.
Open the file and you can see the changed options. The important items are as follows:
# What type of library to build? [0, 1] -- type of the generated database. 0 indicates the static database, and 1 indicates the dynamic database.
Shared = 0
# Compile Unicode build of wxWidgets? [0, 1] -- whether to enable Unicode, 0 NO, 1 is
Unicode = 0
# Type of compiled binaries [debug, release] -- whether it is debug or release
Build = debug
There are also many options as the name suggests. Please modify them as needed.
The options in config. VC can also overwrite the values in the configuration file through the command line, such
D:/wxWidgets-2.8.8> nmake-F makefile. VC shared = 1 Unicode = 1 build = release
It is to compile the release version and support Unicode dynamic libraries.
The differences between the dynamic library and the static library are embodied in usage. The code in the static library can be compiled into the EXE file of the application. This EXE file can be released separately, but it is bulky.
The dynamic library allows the EXE file to be loaded during execution. Although the EXE file is small, the corresponding dynamic library file must be carried during release.
2) VC Compilation
You can also use VC ++ to open D:/wxWidgets-2.8.8/build/MSW/wx. DSW, and then select build-> batch build ...,
We can see that each project has 16 configurations. Please select your configuration as required,
For example, the Win32 release and Win32 DEBUG Versions of all projects, and then build them. If you accept all of them as per your order, compilation will be very time-consuming and take up space.
This compilation method is used to compile all required versions.
Well, after compilation, in the Directory D:/wxWidgets-2.8.8/lib/will generate a directory: vc_lib is the directory of the static library, the default compilation has 17 static.
If it is compiled into a dynamic library, the directory vc_dll will be generated.
The mswd directory is available in vc_lib, And the release version corresponds to the MSW, which contains the setup. h of debug and release versions.
Note that the debug and release versions and the file and directory names generated by compiling with Unicode, dynamic library, and static library combinations.
Static library compiled to D:/wxWidgets-2.8.8/lib/vc_lib directory
Dynamic library compiled to D:/wxWidgets-2.8.8/lib/vc_dll directory
The file named wxmsw28d_core.lib is used as an example:
Wxmsw28_core.lib ---- release, non-Unicode version
Wxmsw28d_core.lib ---- debug, non-Unicode version
Wxmsw28u_core.lib ---- release, Unicode version
Wxmsw28ud_core.lib ---- debug, Unicode
The same applies to DLL files.
In vc_lib and vc_dll, if all the directories are compiled, there will be four directories: MSW, mswd, mswu, and mswud.
After compilation, you can delete the target files in those processes, which occupy too much space.
If you want to re-compile it later, keep it.
Step 3: test whether VC ++ 6.0 can compile wxWidgets sample project
3.1 Add the lib and include file paths of wxWidgets to VC ++ 6.0
Project configuration additional include directories and additional library path.
In addition, it is more appropriate to put the two include files in the following global settings.
Go to the tools-> options-> directories of VC ++, select "include files", and add
D:/wxWidgets-2.8.8/include
D:/wxWidgets-2.8.8/contrib/include
D:/wxWidgets-2.8.8/lib/vc_lib/mswd
Corresponding to additional include directories in Project Settings> C/C ++ tab> Preprocessor
Then select "libraries Files" to add
D:/wxWidgets-2.8.8/vc_lib
3.2 compile and run the minimal. DSW Program
Open Workspace: C:/program files/wxWidgets-2.8.8/samples/minimal. DSW
Compile OK and run it. The configuration is normal!
Step 4: Create the Win32 application wxWidgets project wxhello
Create an empty project for Win32 application named wxhello
Proejct-> Settings (Alt + F7) Go to Project Settings
1. C/C ++ tab-> code generation-> use run-time Library: Debug mutilthread DLL
2. C/C ++ tab-> Preprocessor Definitions
Add _ wxmsw __,__ wxdebug _ to the configuration. if the version is release, add _ wxmsw __.
3. C/C ++ tab-> Preprocessor-> additional include directories
Set to D:/wxWidgets-2.8.8/include, D:/wxWidgets-2.8.8/include/lib/vc_lib/mswd, which is to set the additional include path.
4. Link tab-> input-> Object/library modules
Wxmsw28d_core.lib wxbase28d. Lib wxmongod. Lib wxmongod. Lib wxpngd. Lib wxzlibd. Lib wxregexd. Lib wxexpatd. Lib
These lib (add the first two without the four lib comctl32.lib rpcrt4.lib winmm. Lib wsock32.lib ).
If you want to use wxodbc, add wxbase28d_odbc.lib.
5. Link tab-> input-> addtional library path set to: D:/wxWidgets-2.8.8/lib/vc_lib.
Note: The Execution Code compiled into different versions should be filled with the corresponding additional include directories and addtional library path.
To compile the DLL-dependent execution file, you also need to add the preprocessing command wxusingdll.
To compile with Unicode, add the preprocessing command _ Unicode.
There is also a kind of universal compilation, which requires the preprocessing command _ wxuniversal __
This is a common wxwdigets project.
Let's test the example minimal that comes with wxWidgets. Create a minimal. cpp file,
Content with D:/wxWidgets-2.8.8/samples/minimal. cpp, compilation, no accident, succeeded!
Release static library version (vc_msw) minimal.exe 1.11 M, which can be released separately
Debug static library version (vc_mswd) minimal.exe 2.52 M, which can be released separately
Release dynamic library version (vc_mswdll) minimal.exe 68 K,
Add wxmsw28_core_vc_custom.dll (2.85 m) and wxbase28_vc_custom.dll (1.11 m), a total of 4 m
Debug dynamic library version (vc_mswddll) minimal.exe 96 k,
Add wxmsw28d_core_vc_custom.dll (4.26 m) and wxbase28d_vc_custom.dll (1.82 m), a total of 6.1 m
This is a simple wxWidgets program that only uses two dynamic libraries.
When the wxWidgets library is used, it will be smaller to compile and release files using the static library. If multiple components are used, it may be easier to use the dynamic library. Please decide as appropriate.