Author Topic: errors I can't make sense of  (Read 4487 times)

Offline Jasper

  • Multiple posting newcomer
  • *
  • Posts: 10
errors I can't make sense of
« on: October 09, 2007, 08:05:48 pm »
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
Code
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:
Code

#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
Code
#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
Code

#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
« Last Edit: October 09, 2007, 08:09:43 pm by Jasper »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: errors I can't make sense of
« Reply #1 on: October 09, 2007, 08:30:02 pm »
It is most likely a linking issue.
What library or object file is Triangle class in?
Is it in the Library list?

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jasper

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: errors I can't make sense of
« Reply #2 on: October 09, 2007, 08:48:14 pm »
actually, the triangle class is made in my project (as provided, Triangle.h and Triangle.cpp). I may have misunderstood your question, but these files have the contents that I posted and they are in the project management between the other files.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: errors I can't make sense of
« Reply #3 on: October 09, 2007, 09:19:11 pm »
Turn on Full Compiler Logging, I think this works for MSVC.

Settings -> "compiler and debugger"
Tab "Other Settings" the rightmost tab
Set "Compiler Logging" to "Full command Line"

Rebuild project
Post the "Build Log"

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jasper

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: errors I can't make sense of
« Reply #4 on: October 09, 2007, 09:26:02 pm »
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:

Code
-------------- 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
« Last Edit: October 09, 2007, 09:28:19 pm by Jasper »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: errors I can't make sense of
« Reply #5 on: October 09, 2007, 09:37:45 pm »
Some of the parts of minGW GCC does not like spaces in file names. This might be the cause.

What object file contains triangle code?
DrawEngine.o
ErrorHandler.o
FileHandler.o
Game.o
Scene.o
Vertex.o
main.o
Core.o

The order of object files could be wrong, but I have never had it happen in Code::Blocks. I am guessing the object file with the Triangle class is not in the list above.

Please re-compile the Triangle class and post the Build Log.

Tim S
« Last Edit: October 09, 2007, 09:40:12 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jasper

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: errors I can't make sense of
« Reply #6 on: October 09, 2007, 09:46:11 pm »
That gave me the error that the file was not assigned to any build (knowing the problem now it was easy to fix it).

Thanks a lot for helping me fix this.

Jasper