How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

前端 未结 1 1064
夕颜
夕颜 2021-01-06 01:36

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

相关标签:
1条回答
  • 2021-01-06 02:20

    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.

    0 讨论(0)
提交回复
热议问题