Compiling wxwidgets--windows, vc71, Bcc32, MinGW, and command lines

Source: Internet
Author: User
Tags wxwidgets

Compiling wxwidgets--windows, vc71, Bcc32, MinGW, and command lines

http://www.diybl.com/course/3_program/vc/vc_js/20071226/93502.html#

WxWidgets is a well-known C + + library that provides a graphical interface support that you can use to develop desktop applications (you can also use it to develop console programs, but this is not uncommon).

To put it simply, Wxwidgets has several features:

① Open source. Of course I don't care if it's open source, I just care if it's free.

② is a very good transplant. Supported by many operating systems and compilers, this has been an attractive feature in the C + + world.

③ a local style form. That is, "native look and feel", such as the desktop app that you developed with wxwidgets in Windows, and the programs that were developed using Windows API or MFC, are very similar (or completely consistent) in control style and user perception. This means that the user will get the most familiar feeling when the program is published as a source binary file, and secondly, this means that the wxwidgets form has the most satisfying performance.


Why do you use wxwidgets? I don't know if the above has given you enough reason. For me personally, in addition to the native Program and portability (these two really make me a temptation), learning to use wxwidgets 10 points of special value, that is Wxpython. Wxpython is an infinitely beautiful thing, and its presence makes Python a great choice for developing desktop applications! Elegant Python code, fast development speed, push into C + + user interface response, depth possible visual experience-if not Python and Wxpython need additional runtime environment support, I am afraid I would prefer python as a desktop development language. Wxpython is the transplant of wxwidgets, which makes WX's study doubly valuable. (In fact, Wxpython and Wxwidgets share a document, but this document does not support Python.) )

By the way, after I saw the application developed by Wxpython, I even doubted whether the program developed by Wxwidgets would get a better user response. Wxwidgets not let me down.

Well, Wxpython's beautiful first aside, we have to face the wxwidgets ^_^

This article only discusses the installation, compilation, and testing of wxwidgets under Windows, and the development of Linux and wxwidgets is placed in subsequent articles.


My operating system is Windows XP.

Download and install:

You can find the latest version of the Download (http://www.wxwidgets.org/downloads/) on Wxwidgets's official site, or go directly to Soureforge (http://sourceforge.net/ project/showfiles.php?group_id=9863) Download. If you only need to use under Windows, download WXMSW, if you want to apply on other platforms, you can download Wxall.

When I wrote this article, the latest stable version was 2.8.3.

After the download, run the installation or unzip it to the directory you specified to proceed to the next step. Later we mention "Wxwdigets directory" refers to this installation directory. For example, my wxWidgets directory is f:/libs/wxwidgets-2.8.3.

Tip: Docs/msw/install.txt in the wxwidgets directory is an installation guide and you can get most of the references you need.



Compile:

I'll start by introducing the three compilers I have on hand, VC7.1 (2003), Borland C + + Compiler 5.5,mingw. I assume you have at least one of the compilers installed correctly.

The process of compiling is actually very simple, and the tool we use is the command line. If you're going to use Visual Studio's IDE, we'll give you a hint.


①vc7.1 (Visual Studio. NET 2003)

Note: If you use VC6 or VC8, the process is similar.

To use VC7.1 to compile the wxwidgets, first ensure that the appropriate environment variables are loaded.

Method 0: If your environment variable is automatically registered, then you do not have to load it again. Test method: Start a Command line window (Start menu, run->cmd), typing nmake or CL, if "not internal or external command, also is not a running program or batch file", then your environment variable is not automatically registered, You need to use one of the following methods to load (don't forget to load the test).

Method One: The best approach is to use the command-line tool provided by the VC, starting as follows: Start menu->microsoft Visual Studio. NET 2003-> Visual Studio. NET Tools->visual Studio. NET 2003 command prompt.

Method Two: If you do not find the command line tool in the Start menu, you can manually load a bat,bat location in general: Microsoft Visual Studio. NET 2003/common7/tools/vsvars32.bat. where Microsoft Visual Studio. NET 2003 is your vs.net installation directory. For example, my vs installation directory is f:/microsoft visual Studio. NET 2003, loaded as follows: Start a command-line window (Start menu, run->cmd), and type "F:/microsoft visual Studio. NET 2003/common7/tools/vsvars32.bat "(Note that you need to enclose the quotation marks).

Method Three: If you are using VC6, there may not be vsvars32.bat this file, it's okay, we have a vcvars32.bat. However, take vc7.1 as an example: Start the command-line window and tap F:/microsoft Visual Studio. NET 2003/vc7/bin/vcvars32.bat (Note that you need to enclose the quotation marks). If you are VC6, you need to adjust the path accordingly.

Now that your environment variable is registered, do not close your command-line window! We have a very important thing to do, ^_^.

Take my environment as an example, enter the BUILD/MSW folder under the Wxwidgets directory:

C:/Documents and Settings/username>f:
F:/>CD libs/wxwidgets-2.8.3
F:/LIBS/WXWIDGETS-2.8.3>CD BUILD/MSW
F:/libs/wxwidgets-2.8.3/build/msw>

The next step is to get into the real part of the compilation. There are some options for compiling wxwidgets, you can refer to Docs/msw/install.txt under the wxwidgets directory. Generally, the two most common options are debug/release, and Unicode/ansi. The default compiled version is Debug+ansi.

If you want to use the default option, type:

Nmake-f MAKEFILE.VC

If you want to manually set some compilation options, such as using the Uniocde+release version, type:

Nmake-f MAKEFILE.VC build=release unicode=1

You can of course compile several sets of wxwidgets as you need. On my Machine (2003 machine), compiling a version of WX, probably only takes 5 minutes to function, your machine will probably be faster. Each set of WX requires about 200m~300m of hard disk space.


②borland C + + Compiler 5.5

If you use BCC32, then I assume you have installed the Borland command-line compiler. I'm sorry I didn't use C + + builder, but I think C + + Builder also contains this set of command-line tools.

Using BCC32 requires the Make program provided by Borland. The directory BCC32 installed on my computer is F:/program files/bcc55, so the path to this make is F:/program files/bcc55/bin/make.exe. You might want to put it in an environment variable, which is your preference, but I recommend that you use absolute paths when compiling wxwidgets, because there may be multiple make on your machine and they are almost incompatible (at least on my machine). So when you knock make, you may need extra energy to focus on.

For example, in my environment, go to the BUILD/MSW folder under the Wxwidgets directory:

C:/Documents and Settings/username>f:
F:/>CD libs/wxwidgets-2.8.3
F:/LIBS/WXWIDGETS-2.8.3>CD BUILD/MSW
F:/libs/wxwidgets-2.8.3/build/msw>

The next step is to get into the real part of the compilation. There are some options for compiling wxwidgets, you can refer to Docs/msw/install.txt under the wxwidgets directory. Generally, the two most common options are debug/release, and Unicode/ansi. The default compiled version is Debug+ansi.

If you want to use the default option, type:

"F:/program Files/bcc55/bin/make.exe"-F MAKEFILE.BCC

Note: If you have spaces in your make path (such as program Files), you need to double-quote them around the make path.

If you want to manually set some compilation options, such as using the Uniocde+release version, type:

"F:/program Files/bcc55/bin/make.exe"-F makefile.bcc-dbuild=release-dunicode=1

Note: The variable definition syntax here differs from other make.

If you confirm that your PATH environment variable contains the correct make, you can also knock directly:

Make-f MAKEFILE.BCC

Or:

Make-f makefile.bcc-dbuild=release-dunicode=1

You can compile as many sets of wxwidgets as you need. On my Machine (2003 machine), compiling a bcc32 version of WX, probably only takes 5 minutes, your machine is likely to be faster. Each WX requires about 200M of hard disk space, smaller than VC occupancy.


③mingw

In my conscience, I do not recommend that you use wxwidgets in MinGW.

MinGW version of the compilation step is cumbersome, compile time is long, compiled out of the library is huge. But it is said that MinGW studio comes with a compiled WX, not sure if it is true.

I am referring to this article, so you can also use it as a reference: Http://www.wxwidgets.org/wiki/index.php/Compiling_WxWidgets_With_MSYS-MinGW

First you have to install MinGW (I assume you are already installed), in order to have a Unix-like shell, we also need to install Msys (: http://www.mingw.org/download.shtml).

Note: The Msys installation path cannot have spaces (as I recall).

Install Msys start Msys, a shell appears, enter the Wxwidgets directory. Take my environment for example:

cd/f/libs/wxwidgets-2.8.3

Create a new directory, such as Mingw-debug:

mkdir Mingw-debug

Enter directory:

CD Mingw-debug

To configure MINGW Engineering:

.. /configure--disable-shared--enable-debug

You can use the. /configure--help to see other options, such as compiling Uncode version requires--enable-unicode, compiling release version requires--disable-debug.

This configuration process took me about 10 minutes.

After configuration, run make in the directory:

Make

This process also consumes about 20 minutes, 1.7G of hard disk. It's not pleasant compared to the previous two compilers.


④VC's IDE

If you use VC6, you can also use this method.

Enter the Wxwidgets directory under the BUILD/MSW folder, there is a wx.dsw, run it. You can select the version you want to compile in the build window (that is, the one that normally displays Debug or Release), such as "Win32 Debug", "Win32 Unicode release", or a handy ^_^. (Note: If this window is not displayed, right-click on the toolbar and select "Build" in the pop-up menu.) )

Please refer to ① for the cost of this process time space.



Most of the content compiled here has been completed, and you may want to experience wxwidgets. In the wxwidgets directory there is a samples subdirectory, there are a lot of small programs to show the wxwidgets of the various components, wxwidgets directory has a separate demos directory, there are a few small applications (including a small minesweeper game and card games and other).

You can go to the corresponding Samples directory or subdirectory, and compile the examples as described above by compiling wxwidgets.

Take the controls under samples as an example:

①vc7.1 (Visual Studio. NET 2003)

After configuring the environment variables and compiling the wxwidgets as described previously, go to samples/controls and compile the example as you compiled the library version.

If you are compiling wxwidgets, use the following:

Nmake-f MAKEFILE.VC

Then compile the example with the same command:

Nmake-f MAKEFILE.VC

If you are compiling wxwidgets, use the following:

Nmake-f MAKEFILE.VC build=release unicode=1

So when compiling the example, use:

Nmake-f MAKEFILE.VC build=release unicode=1

If you use "Nmake-f makefile.vc" to compile the library but use the "Nmake-f makefile.vc build=release unicode=1" compilation example, it triggers the library that depends on it being compiled.

②borland C + + Compiler 5.5

After compiling the wxwidgets, go to samples/controls and compile the example as you compiled the library version.

If you are compiling wxwidgets, use the following:

"F:/program Files/bcc55/bin/make.exe"-F MAKEFILE.BCC

Then compile the example with the same command:

"F:/program Files/bcc55/bin/make.exe"-F MAKEFILE.BCC

If you are compiling wxwidgets, use the following:

"F:/program Files/bcc55/bin/make.exe"-F makefile.bcc-dbuild=release-dunicode=1

So when compiling the example, use:

"F:/program Files/bcc55/bin/make.exe"-F makefile.bcc-dbuild=release-dunicode=1

If you use the a command to compile the library and use the B command to compile the example, it will trigger the compilation of the dependent B-Libraries.

Note: If you think you have set the appropriate PATH environment variable and have successfully compiled the wxwidgets with a simple command such as Make-f MAKEFILE.BCC, you should still pay attention at this point. If the Make.exe in your path is not the one in the Bcc bin directory, then you are likely to fail. However, if you get a mistake, consider using the absolute path of Bcc55/bin/make.exe as above.

③mingw

If you have compiled the MinGW under MinGW in the previous way, then go to Samples/controls under the newly created MinGW project directory (like Mingw-debug) (not wxwidgets in the main directory) Controls).

Then just knock:

Make

Because other configurations have been registered with the entire project you've built (such as Mingw-debug).

④VC's IDE

In the example directory there are also corresponding VC6 engineering files, such as CONTROLS.DSW. Open it and select the appropriate version (e.g. "Win32 Debug") to run it.


You can also choose to compile all the samples. Just hit the make command (or use the VC project file in this directory) in the Samples directory (not a subdirectory like controls), and the method is exactly the same as compiling a single example-but please don't try it first!

Compiling a set of wxwidgets all samples takes a very long time and hard disk space (not less than 30 minutes and 1.5G HDD)! So before you get ready to compile all the examples, make sure you have plenty of time and space--and a bit of patience and chongrubujing!

Warning: Do not attempt to compile all samples! with MinGW Unless you have 15G of space and 2 hours of free time-and a bit of boredom and self-sacrifice (if you've done this, you can send me ^_^ the exact data you've counted).


After compiling the examples you need, you can execute the examples. In the corresponding directory (such as controls) there will be a corresponding directory (such as VC_MSWD, if you use the debug version of the VC), there are you expect the executable program. Run it!

In terms of volume, the compiled wxwidgets application, the debug version of about 2M, release version 1M more, than MFC to be larger. But in this age (and in the years to come), the gap between the 1M and the future is irrelevant. Exception: MinGW compiled debug version of the sample size is generally more than 12M! Since I do not have enough space (and time) to compile the release version of Wxwidgets, I do not know how the release version of the application size. If someone compiles these successfully, write to me to tell me the actual data.



Compiling wxwidgets under Windows is over here. Later on, it is likely to write some of the compiled articles under Linux, and how to use WX to build your own applications (including the use of Bakefile).

I think this article must seem very lengthy, it is very difficult for me to detailed slightly it properly. Have good suggestions and criticisms welcome to write to me: [email protected]. You can also leave a message after this, but when I find someone here message is probably one months later, and one months later if you can remember to leave a message here, I am afraid it is more human migration after the matter of Mars.

http://blog.csdn.net/idx001/article/details/5213271

Compiling wxwidgets--windows, vc71, Bcc32, MinGW, and command lines

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.