Review above:
In the previous article, I introduced how to create a package file and create a custom project. Next I will introduce wxwidget installation as agreed. This article is applicable to the dev-CPP and mingw32 compilers.
Chapter 4 download and install wxwidget
This chapter describes how to download and install the wxwidget GUI development library.
First, we need to know that wxwidget is used in Win32. Therefore, we need to download the wxmsw development library. Msw I think you also know what it means. The latest version of wxmsw is 2.5.3. You can download it from www.sf.net or at the address below. Http://umn.dl.sourceforge.net/sourceforge/wxwindows/wxmsw-2.5.3.zip. They are all the same. I usually like downloading with umn.dl.sourceforge.net. Preference. In addition, wsmsw-2.5.3.zip is an installation-free wx. Another wxmsw-2.5.3-setup.zip file must be installed. The difference is not too harsh. If you ask me, I will compare wxmsw-2.5.3.zip.
Then we create a directory named wxWidget-2.5.3 on your drive. Decompress the files in the compressed package to this directory. Decompress all the files. Of course, if you want to solve the problem a little less (at least I want it all), you can solve the following folders and files. Note that the path cannot be changed. Otherwise, it will be too much trouble. (That is to say, the original path is build/MSW/makefile. VC. You cannot use makfile. VC instead)
Build/MSW/config. GCC
Build/MSW/makfile. GCC
Include/
LIB/
Src/
Another contrib directory is not very important. At least you will not use it much during normal use. You can solve the problem if needed, but it is usually compiled only when needed.
In this way, our library is installed. Of course, if you are a friend of Dev-CPP. You can set project parameters according to the custom project I introduced earlier. Here, we add
-I (installation directory)/include/
Add connector Parameters
-L (installation directory)/lib/
Now, this chapter is here.
Chapter 2 wxwidget compilation and wxwidget Compilation
Now we use cmd.com to enter build/MSW. If you set it as described in Chapter 1. Enter
Make-F makefile. GCC
Let make compile the program. After a while. We have installed wxwidget. Enter the demo/bombs/directory and enter
Make-F makefile. GCC
You can try the compilation result. You can use the compilation parameters displayed at the prompt as the link parameters and compilation parameters to compile your own project for mingw32.
After compilation, you will see a file bombs in the gcc_debug directory of bombs. Run it, and a sweeping thunder appears. (I have never been a fan of thunder, maybe my IQ is not high ). Maybe you will subconsciously look at the file volume ...... Wow! You will be scared to find that this program is as large as 12 Mb ....... You don't have to worry, because this is the library for debugging. Therefore, a large amount of debugging content is added. It should also be 12 Mb.
Now let's compile a small wxwidget library. We need to use a parameter during compilation. In build/MSW/, enter
Make-F makefile. GCC build = release
Now, we can get the release library. Compile bombs. Go to the gcc_release directory. The program runs the same way, but the size is much smaller than N. If compressed, the program will be smaller than 1 MB.
However, we need a smaller database. Generally, most of the above compilation methods are introduced on the Internet, which is already quite good. There is usually only the first type. Next I will introduce a special compilation method.
If you have used MFC, you will know that MFC uses a dynamic link library, which can increase the utilization of repeated code. If you update the main program, you do not need to update the content of the dynamic library. Therefore, I will introduce how to compile wxwidget into the dynamic link library.
Similarly, we need to go to the build/MSW/directory. Make is also used. Input
Make-F makefile. GCC build = release shared = 1
Note the case sensitivity first. In addition, the release parameter is required. Otherwise, a terrible dinosaur file will be generated. However, wxwidget cannot be debugged. After a period of compilation, we will get the dynamic link library and library file in lib/gcc_dll. If you want to use it for a long time, copy *. DLL ~ /System32/directory. Or set the path value to this directory. Next we will compile the bombs test. Input
Make-F makefile. GCC build = release shared = 1
This time we will find bombs in the gcc_dll directory. If you run it directly, you will see an error message. Of course, if you copy the dynamic link library to the/system32/directory, you will not see it. Copy bombs.exe to the LIB/gcc_dll/directory. After running, the program interface is displayed. But ...... Look at the volume ...... My day, more than 100 kb. Small enough. Let's use this to develop wxwidget ^_^.
The compiler parameters and connector parameters are listed below for you to create a custom project.
Compiler parameters:
-O2-dhave_w32api_h-d1_wxmsw _-I (wxWidgets)/include-I (wxWidgets)/lib/gcc_dll/MSW-wall-I. -dwxusingdll-I (wxWidgets)/samples-dnopch
Connector parameters:
-Mthreads-l (wxWidgets)/lib/gcc_dll-wl, -- subsystem, windows-mwindows-kernel-lwxtiff-lwxjpeg-lwxpng-kernel-lkernel32-luser32-lgdi32-kernel-lwinspool-lwinmm-lshell32-kernel-lole32-loleaut32- luuid-lrpcrt4-ladvapi32-lwsock32-lodbc32
(WxWidgets) indicates the location where you install wxwidget.
Now, this trip to wxwidget is here. We hope that you can successfully go through step 3.
VOICEOVER:
In fact, I have always liked wxwidget, but the generated files are really scary. So I am afraid to use it again. Later, we switched to GTK. However, I also studied how to reduce the wxwidget size. Therefore, this time I completely reduced the file size. It's a great blessing. However, if you find any problems during compilation. You can post my blog response file. It is best to leave your email address so that I can reply to you as quickly as possible. At the same time, I hope you can follow my article. Http://blog.csdn.net/visioncat. Of course, this series of articles is not over yet. It is still being supplemented. Because I was very busy in the early stage, I was not updated for a few months. Some people mistakenly thought that my article was over. Sorry.
Additional content:
From the reader's reply, it is found that this article is still unclear. Therefore, here is a small supplement.
The reader suggested whether a simpler wxwidget example can be provided. So here I will give you a simple makefile and a main. cpp file.
#Makefile.txt
# This makefile is for wxWidgets that use DLL.
# Change the following wxpath parameters./to the installation directory of your wxwidget.
Wxpath = ./
Cf =-O2-dhave_w32api_h-d1_wxmsw _-I $ (wxpath)/include-I $ (wxpath)/lib/gcc_dll/MSW-wall-I. -dwxusingdll-I $ (wxpath)/samples-dnopch
LF =-mthreads-L $ (wxpath)/lib/gcc_dll-wl, -- subsystem, windows-mwindows-kernel-lwxtiff-lwxjpeg-lwxpng-kernel-lkernel32-luser32-lgdi32-kernel-lwinspool-lwinmm-lshell32-kernel-lole32-loleaut32- luuid-lrpcrt4-ladvapi32-lwsock32-lodbc32
# End of makefile
// Main. cpp
// This file is the main program of wxwidget Using DLL, and is a window (blank)
# Include <wx/wx. h>
Class mainapp: Public wxapp
{
Public:
Virtual bool oninit (void );
PRIVATE:
Wxframe * mainframe;
};
Implement_app (mainapp)
Bool
Mainapp: oninit ()
{
Mainframe = new wxframe (wxframe *) null,-1, "wxwindows ");
Mainframe-> show (true );
Return true;
}
// Main. cpp ends
Now, this supplement is over.
Studio software development group (SDT)
Studio development team
Dipper (Huang yaokui)