Hey so i just took the following steps:
- Downloaded Box2d 2.1.2 and used cmake to build the msVS++ projectiles
- Built Box2D.sln under debug and release, but didn't touch the libs or dlls
- Made a new Win32 project, and copied the code from "Hello World" which was included in the Box2D download into my new projects main source file
- Added an include directory to the same source code used by Cmake to generate the projects
- Added the project "Box2D" (the static library project) to the sollution so i could modify the library's code; generated by cMake
- Added "Box2D" as a refrence under my new projects common properties
- Looked开发者_Go百科 at "Box2D"'s librarian properties and set 'link library dependencies' to YES
- Pondered the question i put as a comment above the includes (please answer that too!)
Here's Hello World.cpp (please answer the question in the comment)
/* I've also added the "Box2D" project generated by cmake, which includes
all the same files that are in folder my include directory points to, so i could alter the code.
Does this mean i should change <Box2D\Box2D.h> to just "Box2D.h" ? */
#include <Box2D\Box2D.h>
#include "StdAfx.h"
#include <cstdio>
int main(int argc, char** argv)
{
B2_NOT_USED(argc);
B2_NOT_USED(argv);
// Define the gravity vector.
b2Vec2 gravity(0.0f, -10.0f);
// Do we want to let bodies sleep?
bool doSleep = true;
// blah blah, rest of code doesn't matter
}
However when trying to run this i get errors such as
1>c:\libraries and headers\box2d_v2.1.2\box2d_v2.1.2\box2d\build\box2d helloworld\box2d helloworld\box2d helloworld.cpp(30): error C3861: 'B2_NOT_USED': identifier not found
which are all about undefined identifiers which ARE defined in the many headers included in Box2D.h. Why doesn't it see them?
Found the problem: didn't see the warning saying that Box2D.h was skipped because it was placed before stafx.h; so i switched the order of the includes.
精彩评论