Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualSpaceEmotion

Posted 25 July 2012 - 06:32 AM

You have declared your static variable Console::prefix, but you have yet to define it. The definition goes in a single source file (the obviously candidate being console.cpp) and looks like this:

string Console::prefix;

You may want to initialise it with a default prefix:
string Console::prefix = "[hello, world]";


I now added the following lines to the Console class in console.cpp (Under "public:"):
Console() {
prefix = "[Log]";
}

Tried to build and got the following error now:
Undefined symbols for architecture x86_64:
  "_main", referenced from:
	  start in crt1.10.6.o
  "Console::prefix", referenced from:
	  Console::setPrefix(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
	  Console::log(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
ld: symbol(s) not found for architecture x86_64

Does is has to do something with the strings maybe? (I personally don't think so though)
Or does it has to be something with the way how I use the fields of the class?

#2SpaceEmotion

Posted 25 July 2012 - 06:32 AM

You have declared your static variable Console::prefix, but you have yet to define it. The definition goes in a single source file (the obviously candidate being console.cpp) and looks like this:

string Console::prefix;

You may want to initialise it with a default prefix:
string Console::prefix = "[hello, world]";


I now added the following lines to the Console class in console.cpp (Under "public:"):
Console() {
prefix = "[Log]";
}

Tried to build and got the following error now:
Undefined symbols for architecture x86_64:
  "_main", referenced from:
	  start in crt1.10.6.o
  "Console::prefix", referenced from:
	  Console::setPrefix(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
	  Console::log(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
ld: symbol(s) not found for architecture x86_64

Does is has to do something with the strings maybe? (I personally don't think so though)
Or does it has to be something with the way how I use the fields of the class?

#1SpaceEmotion

Posted 25 July 2012 - 06:16 AM

You have declared your static variable Console::prefix, but you have yet to define it. The definition goes in a single source file (the obviously candidate being console.cpp) and looks like this:

string Console::prefix;

You may want to initialise it with a default prefix:
string Console::prefix = "[hello, world]";


I now added the following lines to the Console class in console.cpp (Under "public:"):
Console() {
prefix = "[Log]";
}

Tried to build and got the following error now:
Undefined symbols for architecture x86_64:
  "_main", referenced from:
	  start in crt1.10.6.o
  "Console::prefix", referenced from:
	  Console::setPrefix(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
	  Console::log(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in console.o
ld: symbol(s) not found for architecture x86_64

PARTNERS