嘿所以我只是采取了以下步骤:
这是Hello World.cpp(请回答评论中的问题)
/* 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
}
但是在尝试运行时,我会收到错误,例如
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
这些都是关于未定义的标识符,它们在Box2D.h中包含的许多标题中定义。 为什么不看到它们?
答案 0 :(得分:1)
发现问题:没有看到警告说Box2D.h被跳过了,因为它被放置在stafx.h之前的;所以我改变了包含的顺序。