Using B. Stroustrup’s Programming text and the ‘hello world’ program about pg 50 gives errors. I have issues with the “std_lib_facilities.h” include file.
After running (as root) ‘gcc hworld1.cpp’ the output is –
In file included from /usr/include/c++/4.4/ext/hash_map:60,
from std_lib_facilities.h:34,
from hworld1.cpp:1:
/usr/include/c++/4.4/backward/backward_warning.h:28: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
/tmp/ccpwXUYx.o: In function `main':
hworld1.cpp:(.text+0x14): undefined reference to `std::cout'
hworld1.cpp:(.text+0x19): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccpwXUYx.o: In function `__static_initialization_and_destruction_0(int, int)':
hworld1.cpp:(.text+0x41): undefined reference to `std::ios_base::Init::Init()'
hworld1.cpp:(.text+0x46): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccpwXUYx.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
any suggestions how to fix the file, perhaps commenting out the hash portion?
Excited to finally have time to start, but this seems like a little larger than a 1st troubleshooting task. I have tried just using iostream as the include. I’m running this on Ubuntu 11.04. Perhaps I need to update gcc or use g++. Not sure what might ease me past this one. I tried a few things with ‘using … std’ with the … as the appropriate name I cannot recall (oops). Anyone just know the right includes.
here is the code –
#include "std_lib_facilities.h"
int main()
{
cout<<"hiya people\n";
return 0;
}
You should use g++, because gcc is C compiler (not C++).