Build the wxWidgets development environment under VC ++ 6.0

Source: Internet
Author: User
Tags wxwidgets
Similarly to the wxWidgets Development Environment GTK, QT, SWT, and swing built in VC ++ 6.0, 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 Program It 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 official website is: http://www.wxwidgets.org. This article introduces VC ++ 6.0 under how to build wxWidgets development environment, including compiling wxWidgets source code and configuration VC environment. The wxWidgets version is 2.8.8. Step 1: download and install wxWidgets in the http://www.wxwidgets.org/downloads/ to download to the wxWidgets source code. You can download Windows Installation http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8-Setup.exe (11.9 m) or zip compressed version http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip (15.9 m) If we download a wxMSW-2.8.8-Setup.exe, you can run it, 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 by using nmake in the command line. One is to open wx in VC ++. DSW compile, 1) nmake compile run cmd.exe to the command line, enter the Directory D: \ wxWidgets-2.8.8, and then execute D: \ wxWidgets-2.8.8> nmake-F makefile. by default, VC is a static library 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 this file and you can see the changed options. The important items are as follows: # what type of library to build? [] -- Type of the generated database. 0 is a static database, and 1 is a 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 many options as the name suggests. Please modify them as needed. For config. options in VC can also overwrite the values in the configuration file through the command line, such as compiling the command with D: \ wxWidgets-2.8.8> nmake-F makefile. VC shared = 1 Unicode = 1 build = release is to compile the release version. It supports Unicode dynamic libraries. Dynamic library and static library are different in use Code The EXE file that can be compiled into the application can be released separately, but it is large in size. 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 also available VC ++ 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 configurations as needed, such as Win32 release and Win32 DEBUG Versions of all projects, and then build. If you accept all the configurations as per your order, compilation takes a lot of time and space. This compilation method is used to compile all required versions. Good, wait after the 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 file named wxmsw28d_core.lib file as an example: wxmsw28_core.lib ---- release, non-Unicode wxmsw28d_core.lib ---- debug, non-Unicode version wxmsw28u_core.lib ---- release, Unicode version wxmsw28ud_core.lib ---- Debug. Unicode version also has the same naming rules for 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 a. Configure additional include directories and additional library path for the lib and include file path projects added to VC ++ 6.0. In addition, it is more appropriate to put the two include files in the following global settings. Go to the VC ++ tools-> options-> directories, select "include files", add D: \ wxWidgets-2.8.8 \ include D: \ wxWidgets-2.8.8 \ contrib \ include D: \ wxWidgets-2.8.8 \ Lib \ vc_lib \ mswd corresponds to additional include directories in Project Settings> C/C ++ tab> Preprocessor, then select "libraries Files", add D: \ wxWidgets-2.8.8 \ vc_lib B. compile and run minimal. DSW program open workspace: C :\ Program Files \ wxWidgets-2.8.8 \ samples \ minimal. compile and run DSW. The configuration is normal! Step 4: Create a Win32 application wxWidgets project wxhello to create an empty project for Win32 application. The project name is wxhello proejct-> Settings (Alt + F7) and enter Project Settings 1. c/C ++ tab-> code generation-> use run-time library is set to: Debug mutilthread DLL 2. c/C ++ tab-> Preprocessor definitions settings are added with _ wxmsw __,__ wxdebug _. for 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, this is to set the additional include path. 4. link tab-> input-> Object/library modules settings plus wxmsw28d_core.lib wxbase28d. lib wxmongod. lib wxmongod. lib wxpngd. lib wxzlibd. lib wxregexd. lib wxexpatd. lib (none of the four lib comctl32.lib rpcrt4.lib winmm. add lib wsock32.lib. The key is the first two ). Add wxbase28d_odbc.lib to wxodbc. 5. Link tab-> input-> addtional library path is 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 execution file dependent on the DLL, you also need to add the preprocessing command wxusingdll to compile the file using Unicode, and add the preprocessing command _ Unicode and a kind of universal compilation, add the pre-processing command _ wxuniversal _ to a common wxwdigets project. let's test the example minimal that comes with wxWidgets. Create a new minimal. cpp file, the content is the same as D: \ wxWidgets-2.8.8 \ samples \ minimal. cpp, compilation, no accident, succeeded! Release static library version (vc_msw) minimal.exe 1.11 M, debug static library version (vc_mswd) minimal.exe 2.52 m can be released separately, and release dynamic library version (vc_mswdll) minimal.exe 68 K can be released separately, 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, coupled with 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.

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.