Linker error LNK2019

Started by
2 comments, last by GameDev.net 18 years, 4 months ago
When I try to compile my project I get this:

Linking...
SdlWrapper.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Log::Write(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Write@Log@@SAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: bool __thiscall SdlWrapper::SetRes(int,int,int)" (?SetRes@SdlWrapper@@QAE_NHHH@Z)
Debug/TicTacToe.exe : fatal error LNK1120: 1 unresolved externals

Log is a logging class I have. And SdlWrapper is... well a wrapper for sdl. :P Other than that, I dont really know what wrong or where to look.
Advertisement
It sounds pretty straighforward to me. The linker says you didn't define your Log::Write(const std::string&) function.
But I did :P. Here it is:

void Log::Write(const string& logEntry){	if(screenWrite)	{		printf("%s\n", logEntry.c_str());	}	if(fileWrite)	{		log_file << logEntry.c_str() << endl;	}}
Somewhere, though, you should have it defined as a function prototype.

I don't know C++ (C only) so I don't know what the :: are - something to do with inheritance maybe - but you should have something like (overly complex example, so as to demonstrate the problem):

void Log::Write(const string& logEntry);

Somewhere, as a definition of the function. If it's external (won't be available to the C++ compiler, but will be to the linker - say an assembler function or something already compiled to object code) then you'll need something like:

extern void Log::Write(const string& logEntry);

As I say, I don't know C++ at all, so the syntax in terms of those :: might be different.

This topic is closed to new replies.

Advertisement