-2

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

While g++ report "error: undefined reference to 'Log::flush()'", it means I lost a source code which define the member function flush of class Log like this:

class Log{   
   ... ...   
   int flush();   
   ... ... 
};

But if the g++ report "error: undefined reference to 'Log::outFile'", What is lost? There is no () so this is not a function, so why is there anything that needs defining?

Community
  • 1
  • 1

1 Answers1

4

Well, isn't this a fun exercise in GCC diagnostic output jeopardy!


But if the g++ report "error: undefined reference to 'Log::outFile'", What is lost?

More than likely, the definition of a static data member of Log called outFile.

Guessing:

class Log
{
   int flush();
   // ... more functions ...

   static std::string outFile;
   // ... more data ...
};

You'd need to write:

std::string Log::outFile;

in precisely one translation unit; put it in a .cpp file, probably the one in which you placed the definition for Log::flush().

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055