The wxWidgets compilation method recorded on the official forum and on the Internet will lead to a very large library after compilation, because the compilation method is improperly selected.
The following briefly summarizes how to compile the latest SVN code.
Download the latest source code (daily build): http://biolpc22.york.ac.uk/pub/Daily_HEAD/
Or Use Subversion to check out: http://www.wxwidgets.org/develop/svn.htm
Preparations:
1. Delete include/wx/MSW/setup. H (if the file already exists)
2. Modify setup0.h and set the following macro value to 0!
Wxwin_compatibility_2_8
Wxuse_exceptions
GCC version:
Modify the makefile. GCC file: case-sensitive search "_ GCC", ""
Mingw32-make-F makefile. GCC cppflags = "-OS-pipe-mthreads" cxxflags = "-fvisibility = hidden-fvisibility-inlines-hidden-wno-attributes" ldflags = "-wl,-O1-wl, -- Sort-common-wl, -- as-needed-s "shared = 1 build = debug Unicode = 1 debug_info = 0 debug_flag = 1 monolithic = 1 use_exceptions = 0 use_rtti = 0 official_build = 1 runtime_libs = static <br/> mingw32-make-F makefile. GCC cppflags = "-OS-pipe-mthreads" cxxflags = "-fvisibility = hidden-fvisibility-inlines-hidden-wno-attributes" ldflags = "-wl,-O1-wl, -- Sort-common-wl, -- as-needed-s "shared = 1 build = release Unicode = 1 debug_info = 0 debug_flag = 0 monolithic = 1 use_exceptions = 0 use_rtti = 0 official_build = 1 runtime_libs = static
VC version:
Modify the makefile. VC file: search for "_ VC" in case sensitive and replace it ""
Nmake-F makefile. VC cppflags =/OS ldflags = "/manifest: No/OPT: ref/OPT: ICF "build = debug shared = 1 Unicode = 1 debug_info = 0 debug_flag = 1 monolithic = 1 use_exceptions = 0 use_rtti = 0 official_build = 1 runtime_libs = static <br/> nmake-F makefile. VC cppflags =/OS ldflags = "/manifest: No/OPT: ref/OPT: ICF "build = release shared = 1 Unicode = 1 debug_info = 0 debug_flag = 0 monolithic = 1 use_exceptions = 0 use_rtti = 0 official_build = 1 runtime_libs = static
VC static version:
Nmake-F makefile. VC cppflags =/OS ldflags = "/manifest: No/OPT: ref/OPT: ICF "build = release shared = 0 Unicode = 1 debug_info = 0 debug_flag = 0 monolithic = 1 use_exceptions = 0 use_rtti = 0 official_build = 1 runtime_libs = static
During compilation, you can adjust the options as needed. Since I used to compile wxWidgets, a project must be compatible with both VC and GCC compilers, and some small programs, I like to use the static link release method in the final release, so the above three versions are available.
With these options, you can minimize the size of the generated Library and the size of the files to be executed by static links.
You will find that, by using the appropriate method, you can minimize the size of the library generated by wxWidgets.
Take today's SVN source code as an example:
(GCC) wxmsw292u. dll 6.65 MB
(VC version) wxmsw292u. dll 6.66 MB
Static executable files:
(GCC edition) 2.01 MB
(VC version) 1.31 MB
There are two options: use_exceptions = 0 use_rtti = 0 because rtti and exceptions are not used in the wxWidgets library, this will greatly reduce the size of the executable file (about 30% reduction), cancel these two options, it only indicates that rtti and exceptions are no longer supported in the Wx library, but you cannot use rtti and exceptions in programs based on wx without code!
As to whether these two switches cause the lack of Wx functions, I have not found any basis for this.
However, the official wiki supports this practice: http://wiki.wxwidgets.org/Reducing_Executable_Size
It can be determined that the release of the final program using the VC compiler is significantly better than that of GCC (mingw) in terms of program volume and speed ).
If you want to publish a program on windows, we recommend that you use VC.
Note:
- Other methods of optimizing the size of the VC compiler, such as the/align and/merge options, have proved that not only can the binary size after wxWidgets compilation be reduced, but the opposite effect can be achieved.
- The above tests are only passed on the Windows platform and are not verified on the Linux platform.
All rights reserved. If you need to reprint it, please indicate the source!