没有合适的资源?快使用搜索试试~ 我知道了~
运用MinGW和CodeBlocks在Windows上编译wxWidgets及使用
需积分: 1 1 下载量 75 浏览量
2023-10-22
15:17:51
上传
评论
收藏 1.95MB PDF 举报
温馨提示
试读
50页
运用MinGW和CodeBlocks在Windows上编译wxWidgets及使用 从源码编译wxWidgets并使用codeblocks构建wxWidgets应用 MinGW:MSYS2 codeblocks:20.03
资源推荐
资源详情
资源评论
PB’s Guide to Starting with wxWidgets
on Microsoft Windows
with MinGW and Code::Blocks
Guide Author: PB <pbfordev@gmail.com>
Guide Version: 4.6, released September 21, 2023
Versions of Software Used in Guide
wxWidgets: 3.2 (3.2.2.1 at the time of writing)
MinGW: MSYS2 mingw-w64-ucrt-x86_64-toolchain (GCC 13.2 at the time of writing)
Code::Blocks: 20.03
The latest version of this guide is always available at https://github.com/PBfordev/wxpbguide.
Table of Contents
1 Introduction ................................................................................................................................................................ 4
2 Basic wxWidgets Information ................................................................................................................................... 5
2.1 wxWidgets Versions ............................................................................................................................................. 5
2.2 Shared vs Static Linking ....................................................................................................................................... 5
2.3 Multilib vs Monolithic Build ................................................................................................................................... 6
2.4 Debug and Release Configuration ....................................................................................................................... 6
2.5 32-bit vs 64-bit Build ............................................................................................................................................. 6
2.6 To Build or Not to Build ........................................................................................................................................ 6
3 Building wxWidgets with MinGW ............................................................................................................................. 7
3.1 Choosing MinGW Distribution .............................................................................................................................. 7
3.2 Installing MSYS2 .................................................................................................................................................. 7
3.3 Installing MSYS2 Packages for Developing C++ Applications ............................................................................ 7
3.4 Downloading wxWidgets Sources ........................................................................................................................ 9
3.5 Adding System Environment Variable WXWIN .................................................................................................. 11
3.6 The Build ............................................................................................................................................................ 13
3.6.1 Starting Simple ...................................................................................................................................... 13
3.6.2 Improving Build Commands .................................................................................................................. 14
3.6.3 Making wxWidgets Build Faster ............................................................................................................ 15
3.6.4 Viewing Build Results ............................................................................................................................ 16
3.6.5 Using the Minimal Sample to Test the Build.......................................................................................... 17
3.6.6 Cleaning the Build ................................................................................................................................. 19
3.6.7 Building wxWidgets Statically ................................................................................................................ 20
3.6.8 More Build Options ................................................................................................................................ 21
4 Setting Up wxWidgets Project with Code::Blocks and MinGW .......................................................................... 22
4.1 Installing Code::Blocks ....................................................................................................................................... 22
4.2 Configuring the Debugger .................................................................................................................................. 23
4.3 Configuring the Compiler .................................................................................................................................... 24
4.4 Creating Global Variable wx ............................................................................................................................... 25
4.5 Creating a wxWidgets Project with Project Wizard ............................................................................................ 26
4.5.1 Selecting wxWidgets Project Template ................................................................................................. 27
4.5.2 Wizard Page 1: Welcome ...................................................................................................................... 28
4.5.3 Wizard Page 2: wxWidgets Version ...................................................................................................... 29
4.5.4 Wizard Page 3: Project Title and Paths................................................................................................. 30
4.5.5 Wizard Page 4: Project Author .............................................................................................................. 31
4.5.6 Wizard Page 5: GUI Builder and Application Type ............................................................................... 32
4.5.7 Wizard Page 6: wxWidgets Location ..................................................................................................... 33
4.5.8 Wizard Page 7: Compiler and Debug/Release Configurations ............................................................. 34
4.5.9 Wizard Page 8: Various Configuration Options ..................................................................................... 35
4.5.10 Wizard Page 9: Advanced Options ....................................................................................................... 36
4.5.11 Wizard Page 10: Additional Libraries .................................................................................................... 37
4.6 Adjusting Project Settings .................................................................................................................................. 38
4.6.1 Setting C++ Standard Used in the Project ............................................................................................ 39
4.6.2 Setting Preprocessor Define NDEBUG for the Release Build Target ................................................... 40
4.6.3 Marking the Application DPI-Aware ....................................................................................................... 41
4.7 Finally Finished! ................................................................................................................................................. 42
4.8 Extra Reading: wxWidgets Code::Blocks Project Under the Hood .................................................................... 43
4.8.1 Compiler Include Folders....................................................................................................................... 43
4.8.2 Preprocessor Defines ............................................................................................................................ 43
4.8.3 Linker Settings ....................................................................................................................................... 44
4.8.4 Using Static Instead of Shared wxWidgets Build .................................................................................. 45
Document History ......................................................................................................................................................... 47
Chapter 1: Introduction
PB’s Guide to Starting with wxWidgets on Microsoft Windows with MinGW and Code::Blocks (v4.6) Page 4 of 50
1 Introduction
This Microsoft Windows specific guide hopes to assist the readers with decisions regarding which wxWidgets version
and configuration to use and show how to build wxWidgets using MinGW with various parameters affecting the resulting
build. It also describes in detail setting-up a wxWidgets project in popular IDE Code::Blocks.
This guide is not a reference manual, it is a tutorial for new users of wxWidgets, MinGW, and Code::Blocks;
supposed to be followed step by step.
This guide does not cover actual wxWidgets programming nor using Code::Blocks (besides the steps necessary to
set up the IDE to be able to build a wxWidgets project).
This guide assumes that the readers did their research and decided that for their applications, the most suitable
choices as the programming language and the GUI toolkit are C++ and wxWidgets; therefore the pros and cons of these
two choices are not discussed here.
This guide does not intend to replace the official documentation, it hopes to complement it. Its author is not affiliated
with Microsoft, wxWidgets, MSYS2, mingw-w64, or Code::Blocks.
Chapter 2: Basic wxWidgets Information
PB’s Guide to Starting with wxWidgets on Microsoft Windows with MinGW and Code::Blocks (v4.6) Page 5 of 50
2 Basic wxWidgets Information
2.1 wxWidgets Versions
wxWidgets has two supported branches, called stable (currently 3.2) and development (currently 3.3). The stable branch
version always has an even minor version number (e.g., 3.0.5 or 3.2.2) while the development branch has an odd
number for its minor version (e.g., 3.1.7 or 3.3.0). The current development branch is also sometimes called “master”
(e.g., in the GIT code repository) or “trunk” (e.g., in the documentation version selector).
For wxWidgets, when the branch is called stable, the API and ABI of the Major.Minor version is sealed. This means
that all the versions in the stable branch are API- and binary-wise fully compatible, i.e., one can switch to newer releases
of the branch (e.g., from 3.2.0 to 3.2.2) without encountering any (adverse) compile- and run-time differences compared
to the older releases. No such guarantees are made for the development branch and in fact, as new features are added,
the API, ABI, or the run-time behaviour change. In other words, it does not mean that the stable branch is more stable
as in being less prone to crashing your application than the development one. However, it means that no new features
can be added to the stable branch after its initial release. The new releases in the stable branches are for bug fixes only,
but even not all bug fixes can be backported from the development to the stable branch, for example when the code for
the two branches has diverged too much or just no one felt motivated enough to do that. The core developers suggest
that the development branch is generally suitable for production use.
After several years of adding features to the development branch, the developers decide it is ready to become the
new stable branch (e.g., 3.1 became 3.2 after 3.1.7) and a new development branch is created (e.g., 3.3 split from 3.2.0
after its release).
The number of differences in features added (and possibly bugs fixed) between the two branches increases with
the time passed since the initial stable version release. At the time of writing, there has been no release in the current
development branch yet (for comparison, there were eight releases in 3.1 development branch, i.e., between the release
of 3.0 and 3.2). Therefore, if you want to use the development version, you need to embrace the “Live at Head” concept
and use the current GIT master. If you want to do this, make sure to read and follow the GIT instructions. Currently, the
biggest reason for using the development version may be the experimental support for Windows dark mode, about
which you can read about here.
2.2 Shared vs Static Linking
wxWidgets can be built either as the static build or the shared build (the application requires wxWidgets DLL at runtime)
library. Both have their pros and cons, so which one to choose depends on the use case. When the shared configuration
is used, all the necessary DLLs must be shipped with the application and the install package is usually larger than when
using the static libraries where only the used code is linked into the final executable. On the other hand, if one has a
suite of applications using wxWidgets, having them all using the same wxWidgets DLLs is desirable. Similarly, for
applications with plugins, linking to wxWidgets dynamically ensures that both the application and the plugin are using
the same library.
In practice, for most cases the differences from both the user and the programmer’s point of view are usually
negligible, with static linking perhaps being a bit more convenient regarding the application distribution but also being
slower when linking the application during its each and every build.
GCC allows linking the run-time libraries statically, so if all the libraries the application uses can be linked statically
and support being built with the statically-linked compiler run-time libraries, the whole application can be contained in a
single executable which does not require any DLLs at all (see chapters 3.6.7, 4.5.9, and 4.8.4).
I would use the static build only if the application was small, used just wxWidgets as the compiled library and I was
concerned about how much bandwidth and disk space the installer and the installed application take. Otherwise, I would
prefer dynamic linking, i.e., the shared build and this build will be preferably used in this guide.
剩余49页未读,继续阅读
资源评论
debugdebugger
- 粉丝: 7
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Qt开发知识、经验总结 包括Qss,数据库,Excel,Model/View等
- IV数据.xlsx
- 一些深度学习中的小例子,适合新手学习使用
- foldcraftlauncher_262944.apk
- 珍藏多年的基于matlab实现潮流计算程序源代码集合,包含多个潮流计算程序.rar
- 使用FPGA实现串-并型乘法器
- 基于matlab实现针对基于双曲线定位的DV-Hop算法中误差误差出一种基于加权双曲线定位的DV-Hop改进算法.rar
- 基于matlab实现由遗传算法开发的整数规划,车辆调度问题.rar
- 电视家7.0(对电视配置要求高).apk
- 免费计算机毕业设计-基于JavaEE的医院病历管理系统设计与实现(包含论文+源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功