在 x86 中构建 Box2D (Visual Studio)

发布于 2025-01-19 07:38:21 字数 234 浏览 0 评论 0原文

最近,我使用 C++11 和 SDL2 在我们的内部游戏引擎中实现了 Box2D。全新安装 Box2D 将生成 x64 版本。该引擎几年前就被设计为在 x86 中运行,因此仅仅为了匹配 Box2D 而更改项目架构是不可能的。

我找到了一种在 x86 中构建适合我的方法,因此我想将其作为文档发布,以帮助任何遇到同样问题的人。如果有更好的方法,欢迎大家讨论。

那么,如何让 Box2D 与我已经在 x86 中构建的项目一起工作?

Recently I implemented Box2D to our in-house game engine using C++11 and SDL2. A fresh install of Box2D will produce a x64 build. The engine had been built to run in x86 years prior so changing the architecture of the project just to match Box2D was out of the question.

I found a way to build in x86 that worked for me, so I wanted to post this as documentation to help out anyone struggling in the same way. If there is a better way to do it I welcome discussion on the topic.

So, how do I get Box2D to work with my project already built in x86?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

棒棒糖 2025-01-26 07:38:21

首先,您需要安装box2d [box2d -c ++] 。打开命令提示符,然后将存储库克隆到您的计算机上,我选择在“ c:\ temp \'上克隆此”

后,在您完成项目后,在“ Box2D”文件夹中导航并运行 build .bat 脚本。这将安装/编译您需要开始工作所需的所有内容。唯一的缺点是它将在x64中构建,这可能对每个人都不起作用(如果x64对您有用,您可以停止阅读。恭喜!)

第二,如果还没有,请安装VCPKG。您可以关注 [此VCPKG指南]构建VCPKG)。为了方便起见,也将其安装在'c:\ temp \'上。

设置完成后,使用命令提示符导航到VCPKG目录。然后运行以下内容:

 vcpkg install box2d

一旦完成导航到 [path \ to \ vcpkg] \安装\ x86-windows 。在这里,您应该找到所有新的LIB,并包括Box2D的文件。

现在,您可以自由地将这些文件移动到项目需要的任何地方。根据需要编辑项目的属性,您将能够在X86中成功运行代码!

First, you'll need to install Box2D [Box2D - C++]. Open up the command prompt and clone the repo onto your computer, I chose to clone this at 'C:\temp\'

After you've finished pulling down the project, navigate inside the 'box2d' folder and run the build.bat script. This will install/compile everything you'll need to start working. The only downside is that it will build in x64 which might not work for everyone (if x64 works for you, you can stop reading. Congrats!)

Second, if it isn't already, install vcpkg. You can follow [this vcpkg guide] up to step 2 (Run the bootstrap script to build vcpkg). For convenience's sake install this at 'C:\temp\' too.

Once set up is done, use the command prompt to navigate into vcpkg directory. Then run the following:

 vcpkg install box2d

This will run another installation, once it's finished navigate to [path\to\vcpkg]\installed\x86-windows. Here you should find all your new lib and include files for Box2D.

Now you have the freedom to move these files wherever you need to for your projects. Edit your project's properties as needed and you'll be able to successfully run your code in x86!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文