Cocos2d-x Box2D CContactListener构造函数未定义
Xcode Linker Error Cocos2d-x Box2D CContactListener constructor undefined
我试图让Box2D与我的Cocos2d-x项目运行。我添加了碰撞检测,但我得到了一个链接错误架构i386的未定义符号:"CContactListener::CContactListener()",引用自HelloWorldScene.o
中的:HelloWorld::init()我已经尝试了好几种方法,研究了几天,但还是没有弄清楚。任何帮助都会很好。下面是一些代码片段
HelloWorldScene.h
CContactListener *_contactListener; //Variable declared and #include "ContactListener.h" is present at the top
HelloWorldScene.cpp
_contactListener = new CContactListener(); //This line gets the error
_world->SetContactListener(_contactListener);
ContactListener.h
class CContactListener : public b2ContactListener {
public:
CContactListener();
~CContactListener();
std::vector<ContactData>_contacts;
virtual void BeginContact(b2Contact* contact);
virtual void EndContact(b2Contact* contact);
virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
};
ContactListener.cpp
#include "ContactListener.h"
CContactListener::CContactListener(): _contacts()
{
}
CContactListener::~CContactListener()
{
}
//...other functions
CContactListener.cpp未添加到Xcode的目标构建中。我只是在文件检查器中选中了项目的目标框。ccp文件。简单的修复。
相关文章:
- 从python调用openMP共享库时,未定义opnMP函数
- 具有自定义构造函数 (C++) 的类型的动态数组分配
- 当类成员参数具有相同的名称时,如何定义构造函数?
- C++定义构造函数使对象成为非 POD
- 请描述一下在 c++ 中在此类中定义构造函数的方式?
- 不为 emplace() 定义构造函数的解决方法
- CMake 不链接 C 和 C++ 静态库(未定义对函数的引用)
- 已定义构造函数的构造函数无法识别
- 类中未定义的函数
- 在自定义构造函数中的堆上创建指针
- c++ 17 中结构自动定义构造函数的规则是什么?
- 未定义原型函数?
- 模拟 __name__ = __main__ 在 c++ 中会导致错误"未定义类似函数的宏"
- Python 错误:在 SWIG 生成的C++模板化代码模块中没有定义构造函数
- C++11 未定义对函数的引用
- unique_ptr看不到派生类的自定义构造函数
- 两种类型的定义构造函数有什么区别?第一个使用":",第二个用大括号(如函数)定义它
- 为什么一个非平凡的成员需要为同一类中的匿名联合定义构造函数
- 调用函数时未调用构造函数
- c++未定义构造函数