Build a wxWidgets development environment in VC 6.0

Source: Internet
Author: User
Tags wxwidgets
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.7. 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 the official wxWidgets Website: (15.9 m) If we download a wxMSW-2.8.7-Setup.exe, you can run it, during which we assume that the selected installation directory is D: \ wxWidgets-2.8.7. After the installation is complete, we can see that the size of the installation directory is not 127 MB. Note that wxWidgets should be provided with sufficient space. The number of static databases that compile a single version increases to over 300 MB, if you want to compile the dynamic library, select debug or release, ASCII or Unicode, and compile the sample, the final space can be up to 2 GB. Step 2: Compile wxWidgets in two ways. One is to open wx. DSW in VC ++ for compilation, and the other is to compile wxWidgets in the command line. 1) nmake compile run cmd.exe to the command line, enter the Directory D: \ wxWidgets-2.8.7, and then execute D: \ wxWidgets-2.8.7> nmake-F makefile. by default, VC is a static library compiled into the debug version. Maybe we need to make some settings according to our own needs before Compilation: Open D: \ wxWidgets-2.8.7 \ include \ wx \ MSW \ setup. h ensure that the # define wxuse_debug_new_always of line 110th is set to 0. The default value is 0. Set # define wxuse_iostreamh of the first row to 0. Otherwise, the template library of VC cannot be used (under the STD namespace cannot be used ). The default value is 1. If you want to use wxWidgets to provide ODBC classes that support databases, set # define wxuse_odbc to 1. The default value is 1. If you want to generate a dynamic library or a release version, you can modify the D: \ wxWidgets-2.8.7 \ 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 library. 0 is a static library, and 1 is a dynamic library 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 releasebuild = 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.7> 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.7 \ 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.7 \ 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.7 \ Lib \ vc_lib directory dynamic library compiled to D: \ wxWidgets-2.8.7 \ 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: Create a wxWidgets project to create an empty project of Win32 application. The project name is wxhelloproejct-> Settings (Alt + F7) and enter Project Settings 1. c/C ++ tab-> code generation-> use run-time library is set: debug mutilthread dll2. C/C ++ tab-> Preprocessor definitions setting with _ wxmsw __,__ wxdebug _. If it is release, add _ wxmsw __. 3. c/C ++ tab-> Preprocessor-> additional include directories set to D: \ wxWidgets-2.8.7 \ include, D: \ wxWidgets-2.8.7 \ include \ Lib \ vc_lib \ mswd, this is to set the additional include path. 4. link tab-> input-> Object/library modules settings with 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 ). If you want to use wxodbc, add wxbase28d_odbc.lib. 5. Link tab-> input-> addtional library path is set to: D: \ wxWidgets-2.8.7 \ 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 with the same content as D: \ wxWidgets-2.8.7 \ samples \ minimal. cpp, compilation, no accident, succeeded! You can also set the global directory. We configure additional include directories and additional library path for the project. We can set this to global. You do not need to set it separately in the project. The global settings have their own drawbacks and cannot be separated from the Lib files in vc_lib or vc_dll, mswd or wx/setup. H files in MSW. It is necessary to set source files here. In addition, it is more appropriate to put the two include files in the following global settings. Go to VC ++'s tools-> options-> directories, select "include files", add D: \ wxWidgets-2.8.7 \ sorted ded: \ wxWidgets-2.8.7 \ contrib \ sorted ded: \ wxWidgets-2.8.7 \ 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.7 \ vc_lib corresponds to the additional library path in Project Settings> link tab> input and then select "source files", add D: \ wxWidgets-2.8.7 \ SRC last approximate ratio Compare the size of the generated program with the release static library version (vc_msw) minimal.exe 1.11 M, you can separately release the debug static library version (vc_mswd) minimal.exe 2.52 m, release the release dynamic library version (vc_mswdll) minimal.exe 68 K separately, with release (2.85 m) and wxbase28_vc_custom.dll (1.11 M). Four mdebug dynamic library versions (vc_mswddll) minimal.exe 96 k, with wxmsw28d_core_vc_custom.dll (4.26 m) and wxbase28d_vc_custom.dll (1.82 m), a total of M is a simple wxWidgets program, which 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.