I have two errors in my project which I can not make any sense of, and M$VS does not give any problems when compiling the project. As my problem only involves a few of the most simple classes, I will post some of the code here.
The build messages
Debug Win32\Scene.o:: In function `ZN5Scene10initializeEv':C:/Documents and Settings/Jasper/My Documents/Visual Studio 2005/Projects/GameEngine/GameEngine/Scene.cpp:26: undefined reference to `Triangle::Triangle(Vertex, Vertex, Vertex, float)'
Debug Win32\Scene.o:: In function `ZN5Scene6updateEf':C:/Documents and Settings/Jasper/My Documents/Visual Studio 2005/Projects/GameEngine/GameEngine/Scene.cpp:46: undefined reference to `Triangle::update(float
:: === Build finished: 0 errors, 0 warnings ===
both functions are called from Scene.cpp:
#include "Scene.h"
#include "Triangle.h" // included this trying (but failing) to fix the problem
// Triangle.h, Vertex.h and DrawEngine.h are all actually included in the header
Scene::Scene(DrawEngine *arg_drawEngine, ErrorHandler *arg_errorHandler)
{
drawEngine = arg_drawEngine;
errorHandler = arg_errorHandler;
triangle = NULL;
} // Scene
Scene::~Scene()
{
clearAll();
} // ~Scene
bool Scene::initialize()
{
Vertex v1(0.866f, -0.5f, 0.0f);
Vertex v2(0.0f, 1.0f, 0.0f);
Vertex v3(-0.866f, -0.5f, 0.0f);
/* ---------------------- the following line gives our first error ------------------------ */
triangle = new Triangle(v1, v2, v3, 0.0f);
if (!triangle)
{
return false;
}
return true;
} // initialize
bool Scene::clearAll()
{
SAFE_DELETE(triangle);
return true;
} // clearAll
bool Scene::update(float deltaTime)
{
/*----------------- and this line gives the next error------------------- */
triangle->update(deltaTime * 30.0f);
drawEngine->render(triangle);
return true;
} // update
So... now I'll give the code tha (doubly) shows that the parameters are as they should be
Triangle.h
#ifndef Triangle_h
#define Triangle_h
#include "Vertex.h"
class Triangle
{
public:
Triangle(Vertex vertex1, Vertex vertex2, Vertex vertex3, float arg_angle);
virtual ~Triangle();
void update(float arg_angle);
Vertex v1;
Vertex v2;
Vertex v3;
float angle;
};
#endif // Triangle_h
and Triangle.cpp
#include "Triangle.h"
Triangle::Triangle(Vertex vertex1, Vertex vertex2, Vertex vertex3, float arg_angle)
{
v1 = vertex1;
v2 = vertex2;
v3 = vertex3;
angle = arg_angle;
} // Triangle
Triangle::~Triangle()
{
} // ~Triangle
void Triangle::update(float arg_angle)
{
angle += arg_angle;
} // update
To be more clear, I use GCC (MinGW) in codeblocks and I tried the same project in the MSVC IDE and there it worked. I will try what you said now.
edit, here's the log:
-------------- Build: Debug Win32 in GameEngine ---------------
mingw32-g++.exe -LC:\MinGW\lib -o GameEngine.exe "Debug Win32\DrawEngine.o" "Debug Win32\ErrorHandler.o" "Debug Win32\FileHandler.o" "Debug Win32\Game.o" "Debug Win32\Scene.o" "Debug Win32\Vertex.o" "Debug Win32\main.o" "Debug Win32\Core.o" -lglfw -lopengl32 -luser32 -lglu32 -mwindows
Debug Win32\Scene.o: In function `ZN5Scene10initializeEv':C:/Documents and Settings/Jasper/My Documents/Visual Studio 2005/Projects/GameEngine/GameEngine/Scene.cpp:26: undefined reference to `Triangle::Triangle(Vertex, Vertex, Vertex, float)'
Debug Win32\Scene.o: In function `ZN5Scene6updateEf':C:/Documents and Settings/Jasper/My Documents/Visual Studio 2005/Projects/GameEngine/GameEngine/Scene.cpp:46: undefined reference to `Triangle::update(float)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings