[英]Building wxWidgets Hello world
The wxWidgets hello world example does not provide sufficient information to build wxWidgets in any one particular environment. wxWidgets hello world 示例没有提供足够的信息来在任何特定环境中构建 wxWidgets。
The Code::Blocks wxWidgets hello world example does provide sufficient information, but it does not seem likely that a newbie, or even a quite sophisticated user, could figure out all the necessary steps on their own, because there are arcane magic words required. Code::Blocks wxWidgets hello world 示例确实提供了足够的信息,但是新手,甚至是非常老练的用户似乎不太可能自己弄清楚所有必要的步骤,因为需要一些神秘的魔法词。
The Code Yarns example uses CMake, thus could run in many particular environments, but seems to assume that you have already set up wxWidgets and compiled it for your particular environment, and there does not seem to be a CMakeLists.txt file to compile wxWidgets for your particular environment. Code Yarns 示例使用 CMake,因此可以在许多特定环境中运行,但似乎假设您已经设置了 wxWidgets 并为您的特定环境编译了它,并且似乎没有一个 CMakeLists.txt 文件来编译 wxWidgets你的特定环境。
wxWidgets is supposed to be cross platform and cross environment, and I am trying to set up a project to compile in several environments: on Windows10 Visual Studio, Windows 10 TDM-GCC, Windows 10 Code::Blocks, Ubuntu Code::Blocks, and Ubuntu 10 gcc. wxWidgets 应该是跨平台和跨环境的,我正在尝试建立一个项目在几个环境中编译:在 Windows10 Visual Studio、Windows 10 TDM-GCC、Windows 10 Code::Blocks、Ubuntu Code::Blocks、和 Ubuntu 10 gcc。
And apart from the Code::Blocks environments, having trouble.除了 Code::Blocks 环境,还有问题。 Apart from Code::Blocks, I cannot find "Hello World" examples that actually set up wxWidgets on the target so that the Hello World will actually compile and run.除了 Code::Blocks,我找不到在目标上实际设置 wxWidgets 以便 Hello World 实际编译和运行的“Hello World”示例。
The wxWidgets samples directory is not particularly useful, since the samples assume an environment, and do not describe setting up that environment and the actions that will cause the sample to build and run. wxWidgets 示例目录并不是特别有用,因为示例假定一个环境,并且没有描述设置该环境以及将导致示例构建和运行的操作。
Installation guide安装指南
I know this is a old question but I struggled really hard to find a guide for an installation on wxwidgets.我知道这是一个老问题,但我很难找到在 wxwidgets 上安装的指南。 You can use the vckpg importer by Microsoft.您可以使用 Microsoft 的 vckpg 导入程序。 Make sure you have git installed before you follow this routine.在遵循此例程之前,请确保已安装 git。 I will write this for Windows with Visual Studio 2017:我将使用 Visual Studio 2017 为 Windows 编写此代码:
git clone https://www.github.com/Microsoft/vcpkg
将以下存储git clone https://www.github.com/Microsoft/vcpkg
到您选择的目录: git clone https://www.github.com/Microsoft/vcpkg
vcpkg
folder然后打开powershell(ps)(以管理员身份运行)并导航到克隆的vcpkg
文件夹Now in ps, while you are in the vcpkg folder run the following command \\.vcpkg integrate install
so we have a user-wide integration of the vcpkg paket manager and can #include libraries in our c++ projects现在在 ps 中,当您在 vcpkg 文件夹中时,运行以下命令\\.vcpkg integrate install
这样我们就有了 vcpkg 包管理器的用户范围集成,并且可以在我们的 C++ 项目中#include 库
Now to install wxwidgets 32-Bit run \\.vcpkg install wxwidgets --triplet x86-windows
.现在安装 wxwidgets 32 位运行\\.vcpkg install wxwidgets --triplet x86-windows
。 For the 64-Bit Version run \\.vcpkg install wxwidgets --triplet x64-windows
对于 64 位版本运行\\.vcpkg install wxwidgets --triplet x64-windows
YOUR_FOLDER_PATH\\vcpkg\\packages\\wxwidgets_x64-windows\\include;YOUR_FOLDER_PATH\\vcpkg\\packages\\wxwidgets_x64-windows\\lib
.然后转到 C/C++ -> General -> Additional Include Directories 并添加以下文件夹YOUR_FOLDER_PATH\\vcpkg\\packages\\wxwidgets_x64-windows\\include;YOUR_FOLDER_PATH\\vcpkg\\packages\\wxwidgets_x64-windows\\lib
。 Do the same for the x86 configuration but with the wxwidgets_x86-windows
folderpath instead.对 x86 配置执行相同操作,但使用wxwidgets_x86-windows
夹路径代替。WXUSINGDLL=1
(do it for the x64 and for the x86 plattform configuration if you want to use both)作为最后一步,在 C/C++ -> Preprocessor 下的属性中,在 Preprocessordefinition 点下添加以下内容作为额外的点WXUSINGDLL=1
(如果您想同时使用两者,请为 x64 和 x86 平台配置执行此操作)Now you should be able to use the library and run the hello world project.现在您应该能够使用该库并运行 hello world 项目。
To build an app, first you need to have the library compiled.要构建应用程序,首先需要编译库。 To achieve that you can get precompiled binaries or the sources (see Downloads ) and compile them yourself (see Building ).为此,您可以获取预编译的二进制文件或源代码(参见下载)并自行编译(参见构建)。
Instructions might still not be perfect for everyone, and you are welcome to improve them - even call it your first contribution ;)说明可能仍然不适合所有人,欢迎您改进它们 - 甚至称其为您的第一个贡献;)
我正在寻找的安装说明可以在 wxWidgets/docs/install.txt 中找到
There are multiple ways to setup wxWidgets on Windows and use it in a project.有多种方法可以在 Windows 上设置 wxWidgets 并在项目中使用它。 If your project is going to use CMake there are 2 main options (other than compiling stuff yourself some other way):如果您的项目要使用 CMake,则有 2 个主要选项(除了以其他方式自己编译东西):
SET(wxWidgets_ROOT_DIR "c:/wxwidgets/") SET(wxWidgets_ROOT_DIR "c:/wxwidgets/")
SET(wxWidgets_LIB_DIR "c:/wxwidgets/lib/vc14x_x64_dll") SET(wxWidgets_LIB_DIR "c:/wxwidgets/lib/vc14x_x64_dll")
SET(wxWidgets_CONFIGURATION "mswd")设置(wxWidgets_CONFIGURATION“mswd”)
The LIB_DIR is using VS2019 x64 in my case.在我的情况下,LIB_DIR 使用的是 VS2019 x64。 mswd just means build this for Debug mswd 只是意味着为 Debug 构建这个
Finally, when adding the executable, do not forget the WIn32:最后,在添加可执行文件时,不要忘记 WIn32:
add_executable(membot WIN32 ${project_SRCS})
PS: Remember to extract the headers include folder near the lib . PS:记得在lib附近提取头文件包含文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.