error: undefined reference to:

I am getting these three error messages:
In function `RayTracer::trace(Image&, Scene&)':|
|45|undefined reference to `Scene::getSphereReference(int)'|
|50|undefined reference to `Scene::getSphereReference(int)'|
|51|undefined reference to `Scene::getSphereCenter(int)'|


However in the top of the RayTracer.cpp file, file where this trace function belongs, there is a #include "RayTracer.h" . This header file includes three other header files, one of them it is the Scene.h header file that contains the declaration of the two methods mentioned in the error messages.

So I don't know what I am doing wrongly: The methods are being called from RayTracer.cpp, which includes RayTracer.h, which includes three other header files, one of them it is Scene.h, which includes the declarations of the methods above, these are defined in the Scene.cpp, in which I didn't forgot to include the Scene.h

I am also receiving these warnings:
Scene.h|10|warning: inline function 'Sphere& Scene::getSphereReference(int)' used but never defined|
Scene.h|11|warning: inline function 'Point& Scene::getSphereCenter(int)' used but never defined|


Here the definition of them
1
2
3
4
5
6
7
8
9
#include "Scene.h"

inline Sphere& Scene::getSphereReference (int i) {
    return sphereContainer[i];
}

inline Point& Scene::getSphereCenter (int currentSphere) {
    return sphereContainer[currentSphere].center;
}


Here is the declaration of them:
1
2
3
4
5
6
class Scene {
  public:
    int getSphereContainerSize ();
    void addSphere (const Sphere &sphere);
    inline Sphere& getSphereReference (int i);
    inline Point& getSphereCenter (int currentSphere);


RayTracer.h

1
2
3
4
5
#include "GeometricObjects.h"
#include "Image.h"
#include "Scene.h"

class RayTracer {


Thanks for the help.
Are the header files in your project directory? I don't see anything wrong with the code it self.

You might need to specify more of a path in the include statement, if the file is elsewhere.Or you may be able to specify directories in your project settings somewhere.

HTH
inline functions have external linkage.

Put them in the header file or remove the inline modifier.
Thanks to both.
Topic archived. No new replies allowed.