I recently started a project in Dev-C++ version 4.9.9.2. When I try to compile, the linker returns with several errors:
[Linker error] undefined reference to `os::Timer::initTimer(void)'
[Linker error] undefined reference to `os::Timer::getTime(void)'
[Linker error] undefined reference to `os::Timer::getTimer(void)'
My project has a few files:
- main.cpp
- os.cpp
Both include 'os.h', which contains the following:
class Timer
{
public:
static inline void initTimer( );
static inline u32 getTime( );
};
In 'os.cpp', the functions are defined.
inline void Timer::initTimer( )
{
// The variables below are defined globally and don't
// seem to be part of the problem.
bUseHighFreq = QueryPerformanceFrequency( &sHighFreq );
};
inline u32 Timer::getTime( )
{
if( bUseHighFreq )
{
LARGE_INTEGER sTime;
QueryPerformanceCounter( &sTime );
return u32( ( sTime.QuadPart ) * 1000 + ( sHighFreq.QuadPart / 1000 ) );
};
return GetTickCount( );
};
The code in 'main.cpp' is a test function that is very simple.
int main( )
{
using namespace os;
Timer::initTimer( );
Tell( "Start:\t%i", Timer::getTime( ) );
for( int i = -32000; i < 32000; i++ )
sqrt( cos( sin( 81 ) ) ); // This is just to waste some time.
Tell( "End:\t%i", Timer::getTime( ) );
system( "PAUSE" );
return 0;
};
I clearly declared the functions before using them, and defined them within the project. Please help me figure out why I am getting these errors.