undefined reference to
Nov 4, 2013 at 3:24pm UTC
hi guys
i was working on a error manager and come across with a problem
i declare this at defines.h and it is global
extern std::string fgeError;
core.h
includes
defines.h
and
includes.h
. also
defines.h
includes
includes.h
and i use this
fgeError
at
core.cpp
. this function is defined in a namespace
1 2 3 4 5 6 7
void Logger(std::string message)
{
fgeError.clear();
fgeError.append(message.c_str());
fgeError.append(" - " );
fgeError.append(SDL_GetError());
}
all i want is to make a string which holds last error. i use SDL2 and the compiler gives me
undefined reference to `fgeError'
error
sorry i cant post all the codes, it is so large any info you need will be sent just tell me
Nov 4, 2013 at 3:30pm UTC
the extern
keyword tells the compiler that the object is defined somewhere else, hence you need to define it somewhere else (core.cpp) like so:
std::string fgeError; // Note: without extern
[Beware threading when using globals]
Nov 4, 2013 at 3:46pm UTC
thx
Topic archived. No new replies allowed.