Hi, this is my first post to this forum.
I'm trying to learn the box2d library making a MFC C++ project in VS 2010. Base code has been taken from Nehe OpenGL tutorials web site. I have added a header and a source file to the project namely box2DObject.h and box2DObject.cpp . And I have created a class box2DObject as shown below (first code block is the header and the other is the source file) . But when I have implement the constructor in the source file compiler gave "the unresolved external symbol error" as below: On the other hand if I implement the constructor in the header file compiler gave no error. What could be the reason ? Does anyone knows a compiler option to eliminate this error ?
1>------ Build started: Project: NeheMFC, Configuration: Debug Win32 ------
1> box2DObject.cpp
1> Generating Code...
1> Compiling...
1> Main.cpp
1> Generating Code...
1>box2DObject.obj : error LNK2019: unresolved external symbol "public: __thiscall b2World::b2World(struct b2Vec2 const &,bool)" (??0b2World@@QAE@ABUb2Vec2@@_N@Z) referenced in function "public: __thiscall box2DObject::box2DObject(void)" (??0box2DObject@@QAE@XZ)
1>.\Debug\NeheMFC.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code:
#include "stdafx.h"
#include <Box2D\Box2D.h>
class box2DObject
{
public:
box2DObject();
b2Vec2 gravity;
bool doSleep;
b2World* world;
};
Code:
#include "stdafx.h"
#include "box2DObject.h"
box2DObject::box2DObject()
{
gravity.Set(0.0f,-10.0f);
doSleep=true;
world=new b2World(gravity,doSleep);
}