我将如何构建Box2D在Code :: Blocks / Mingw32(Windows) [英] How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

查看:229
本文介绍了我将如何构建Box2D在Code :: Blocks / Mingw32(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,标题几乎说这一切。我一直在尝试不同的方法,从互联网来源,但每当我尝试出错了。这是我得到了 Box2D



cMake 中,我得到了一堆错误当我正在通过readme.txt中的步骤,但很遗憾,他们的Visual C ++ ...)



所以我想知道热设置(.lib或.a),并在我的项目中使用它(我的朋友传递了他的库,当我加载它,并尝试 #include box2d头,他们没有读的(我有一个未定义的错误列表)他的box2d是我相信为linux / unix,所以我认为这个原因...)


$ b $

如果任何人可以帮助提供一些可能会很好的步骤。



< >解决方案

假设:
您已安装cmake。
你已经安装了Code :: Blocks / MinGW到C:\codeblocks。
您已下载Box2D并将其解压缩到C:\Box2D_v2.1.2。



如果有任何错误,请修改路径以匹配您的。



导航到Box2DBuild文件夹:

cd C:\Box2D_v2.1.2\Box2D\Build



创建makefile :

cmake -GMinGW Makefiles..



>
mingw32-make



这将引发一些警告,但应该几乎完全工作。然后,接近结束,它将试图编译测试床时出错。 AFAIK,没有办法编译使用MinGW的Testbed(你必须使用Visual Studio,我相信)。幸运的是,它的一个.exe在Box2D网站上可用。



在Box2D\Build\Box2D文件夹中,现在应该有一个文件名为libBox2D.a 。将此文件复制到C:\codeblocks\mingw\lib。



将Box2D \Box2D文件夹(包含Box2D.h的文件夹)复制到C: \\ codeblocks\mingw\include。
[因此,在这一步后,你应该有一个文件C:\codeblocks\mingw\include\Box2D\Box2d.h,而不是C:\codeblocks\mingw\include \\Box2d.h]



就是这样。你应该能够编译并运行Hello Box2D示例。不要忘记链接到图书馆。





我想猜测你的MinGW路径环境变量没有正确设置。这是不寻常的,因为当你安装Code :: Blocks / MinGW它通常设置它为你,我相信。



无论如何,右键单击[我的]计算机 - >属性 - >高级系统设置

单击环境变量

根据您所使用的Windows,您可能会看到用户变量和系统变量,或者它可能只是一个组(我不记得名称)。无论如何,创建一个名为MINGDIR的新的系统环境变量,其值为 C:\ codeblocks\mingw 或安装到的位置。然后,找到名为Path(或PATH)的变量,并将其附加到结尾: C:\codeblocks\mingw\bin 。将分号放在上一条目的末尾,并且不要使用空格。

还要确保 C:\CMake\bin 存在于称为Path的系统变量中,或称为Path的用户变量。如果没有,请将它附加到结尾。

我认为就是这样。


hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D

in cMake, i get a bunch of errors when building it(i was going through the steps in the readme.txt, but onfortunately, theyre for Visual C++...)

so im wondering hot to set this up as i guess a library (.lib or .a) and use it in my project(my friend passed me his library and when i loaded it in and tried #includeing the box2D headers, they didnt read at all(i got a list of undefined errors) also his box2d was i believe made for linux/unix so i think thats the reason...)

if anyone can help provide some steps that would be nice.

thanks for reading.

解决方案

Assumptions: You have installed cmake. You have installed Code::Blocks/MinGW to C:\codeblocks. You have downloaded Box2D and extracted it to C:\Box2D_v2.1.2.

If any of those are wrong, modify the paths to match what you have.

Start->Run->cmd.

Navigate to the Box2D "Build" folder:
cd C:\Box2D_v2.1.2\Box2D\Build

Create the makefiles:
cmake -G "MinGW Makefiles" ..

Do it:
mingw32-make

This will throw some warnings, but should work almost completely. Then, near the end, it will error trying to compile the Testbed. AFAIK, there is no way to compile the Testbed using MinGW (you have to use Visual Studio, I believe). Luckily, an .exe of it is available on the Box2D site.

In the Box2D\Build\Box2D folder, there should now be a file called libBox2D.a. Copy this file into C:\codeblocks\mingw\lib.

Copy the Box2D\Box2D folder (the one containing Box2D.h) into C:\codeblocks\mingw\include. [Thus, after this step, you should have a file C:\codeblocks\mingw\include\Box2D\Box2d.h, and NOT C:\codeblocks\mingw\include\Box2d.h]

And that's it. You should be able to compile and run the "Hello Box2D" example. Don't forget to link to the library.

[EDIT]

From the looks of your error, I'm going to guess that your MinGW Path environment variable is not setup correctly. Which is unusual, since when you install Code::Blocks/MinGW it usually sets it for you, I believe.

Anyway, (these steps may vary slightly depending on your version of Windows):

Right-click on "[My] Computer"-> Properties -> Advanced System Settings
Click "Environment Variables"
Depending on which Windows you have, you may see User Variables and System Variables, or it may be just one group (I can't remember the name). Anyway, create a new System Environment Variable called MINGDIR, with the value C:\codeblocks\mingw or wherever you installed it to. Then, find the variable called Path (or PATH) and append this to the end: C:\codeblocks\mingw\bin. Put a semicolon at the end of the previous entry, and do not use a space.
Also make sure that C:\CMake\bin is present in either the System Variable called Path, or the user variable called Path. If not, append it to the end.
I think that's it.

这篇关于我将如何构建Box2D在Code :: Blocks / Mingw32(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆