Q:

Undefined reference

I'm having troubles to compile my C++ project because I get an Undefined reference error.
I have 2 classes:  
Vector3.h  
class Vector3  
{  
public:
float x, y, z;
float v[3];  
Vector3();  
Vector3(float x, float y, float z);  
float mag();  
void normalize();  
void invert();  
void assign(float x, float y, float z);  
Vector3& operator += (const Vector3& in);  
Vector3& operator -= (const Vector3& in);  
Vector3& operator *= (const float& in);  
Vector3& operator /= (const float& in);  
Vector3 operator - ();  
static const Vector3 vZero;  
}; 

Vector3.cpp  
#include "Vector3.h"

inline void Vector3::assign(float inx, float iny, float inz)  
{  
x = inx;  
y = iny;  
z = inz;  
}  

inline float Vector3::mag()  
{  
return (float)sqrt( (*this) * (*this));   
}  

inline void Vector3::normalize()  
{  
float invMag = 1.f/mag();     
(*this) *=  invMag;  
}  

Ray.h  
#include "Vector3.h"  

class Ray  
{  

public:  
Vector3 origin;  
Vector3 direction;  
Vector3 destination;  
float distance;  

Ray();  
Ray( Vector3 o, Vector3 d);  
void setOrigin(float x, float y, float z);  
void setOrigin(const Vector3& v);  
void findDirection(void);  
void setDestination(float x, float y, float z);  
void setDestination(const Vector3& v);  
void findDestination(void);  
void setDirection(const Vector3& v);  
void normalizeDirection(void);  
};  

Ray.cpp  
#include "Ray.h"  

void Ray::findDirection(void)  
{  
direction = destination - origin;  
distance = direction.mag();  
direction.normalize();  
}

When I compile it using Eclipse IDE I get:  
/Ray.cpp:39: undefined reference to `Vector3::mag()'  
/Ray.cpp:40: undefined reference to `Vector3::assign(float, float, float)'  
/Ray.cpp:41: undefined reference to `Vector3::normalize()'  

The header files are included and the auto complete tool works OK, it shows (recognize) the methods: mag, assign and normalize.  
I compiled the files using "g++ -c" to create the .o files because eclipse didn't find them. But the error is still there.  
Does anyone know a solution for this problem?  
Please note that the files Vector3.cpp and Ray.cpp only show the code related to this problem.
Thanks for your help!  

A:

In Vector3.cpp, remove the inline modifier from your functions, or move the function definitions to Vector3.h.
C++ compilers cannot inline functions across modules.  You cannot define an inline function in one module and call it from another.
Edit:
From The C++ Programming Language, pg 199: "An inline function must be defined - by identical definitions - in every translation unit in which it is used."  pg 200: "To ensure consistency, you should usually place global consts and inlines in header files only."

