简体   繁体   English

构建 wxWidgets Hello world

[英]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 编写此代码:

  1. Clone the following repository to a directory of your choice: git clone https://www.github.com/Microsoft/vcpkg将以下存储git clone https://www.github.com/Microsoft/vcpkg到您选择的目录: git clone https://www.github.com/Microsoft/vcpkg
  2. Then open up powershell (ps) (run it as admin) and navigate to the cloned vcpkg folder然后打开powershell(ps)(以管理员身份运行)并导航到克隆的vcpkg文件夹
  3. 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 库

  4. 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

  5. Now open up the properties of your project in Visual Studio.现在在 Visual Studio 中打开项目的属性。
  6. For the integration of the 64-Bit wxwidgets version choose all configurations and as plattform x64.对于 64 位 wxwidgets 版本的集成,请选择所有配置并作为 x64 平台。 Then go to C/C++ -> General -> Additional Include Directories and add the following folderpath 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夹路径代替。
  7. As a last step go to in the properties under C/C++ -> Preprocessor and under the point Preprocessordefinition add the following as extra point 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 个主要选项(除了以其他方式自己编译东西):

  1. Use vcpkg - which, in theory, is the easiest, but I couldn't get it to work (in time).使用 vcpkg - 理论上,这是最简单的,但我无法让它工作(及时)。 Here is some info on that: https://www.wxwidgets.org/blog/2019/01/wxwidgets-and-vcpkg/ The problem is find_package couldn't find the package, so then I just went to 2:以下是一些相关信息: https ://www.wxwidgets.org/blog/2019/01/wxwidgets-and-vcpkg/ 问题是 find_package 找不到包,所以我只去了 2:
  2. Download the lastest compiled headers, libs & bins from the wxwidgets and put them in a folder like c:/wxwidgets .从 wxwidgets 下载最新编译的头文件、库和 bins 并将它们放在像c:/wxwidgets这样的文件夹中。 Then, in your Cmake file, before the call to find_package , do:然后,在您的 Cmake 文件中,在调用find_package之前,执行以下操作:

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.

相关问题 使用 Visual Studio 2019 构建 Hello World wxwidgets 应用程序时出错 - error while building a Hello World wxwidgets app with visual studio 2019 wxWidgets Hello World 示例未编译 - wxWidgets Hello World example not compiling 无法编译 wxWidgets Hello World - Cannot compile wxWidgets Hello World 为什么 wxCrafter Hello World 程序不起作用? [C++,wxWidgets] - Why is wxCrafter Hello World program not working? [C++, wxWidgets] WxWidgets Hello World无法编译:“ wchar_t必须可用” - WxWidgets Hello World fails to compile: “wchar_t must be available” C ++ Hello World的简单构建 - Simple Building for a C++ Hello World 如何使用 CLion 和 MSVC 编译器工具链编译 wxWidgets Hello World 应用程序而不会出错? - How do I compile a wxWidgets Hello World app with CLion and the MSVC compiler toolchain without errors? 从代码块开始,构建Hello World无效(拒绝权限) - Starting with codeblocks, building a Hello world does not work (Permission denied) 在Visual C ++中使用makefile构建hello_world时遇到问题 - Trouble building hello_world with a makefile in Visual C++ 构建 TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] 错误 1 - Building TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] Error 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM