Image

Imageve4cib wrote in Imagecpp

Visual Studio 2k5 + ctime Linker Errors

I'm currently writing a statistical model in C++ at work and am encountering some really strange linker errors. As the title says, I'm working in VS 2005, in a Windows XP environment.

The specific error I'm having has to do with the time(null) function in the ctime header. Because of the statistical nature of the application I need a random number generator, and want to seed it with the return from either time(null) or clock().

Here's the code that's causing the problem:


//
// cRandom.cpp: a random number generator with the option of using fixed seeds
// and producing various different distributions (bell-curves, linear, etc...)
//
#include <ctime>
#include "cRandom.h"        //cRandom object header

cRandom::cRandom()
{
    this->seed = static_cast(time(null));
    srand(this->seed);
}

...


When I try to compile I get this error message:
cRandom.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) __int64 __cdecl _time64(__int64 *)" (__imp_?_time64@@YA_JPA_J@Z) referenced in function "__int64 __cdecl time(__int64 *)" (?time@@YA_JPA_J@Z)
[path removed by ve4cib] : fatal error LNK1120: 1 unresolved externals



I've spent all morning trying to figure out what's going on. I've tried changing the "Use of MFC" option under Project Properties, along with a host of other proposed solutions from various websites but nothing's worked. If anyone has any suggestions or has encoutered this error before I'd really like to hear from you. Thanks a lot!