Sign in to follow this  
Mizipzor

Linker error LNK2019

Recommended Posts

Mizipzor    247
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.

Share this post


Link to post
Share on other sites
SiCrane    11839
It sounds pretty straighforward to me. The linker says you didn't define your Log::Write(const std::string&) function.

Share this post


Link to post
Share on other sites
Mizipzor    247
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;
}
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this