ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have mandrake 10.1 linux OS and gcc-3.4.1-4mdk version.
so i wrote just a sample prog to test gcc ,in that prog i used
Quote:
std::cout<<"hello"<<'\n';
instruction.
so while compiling i got messages telling errors with std
like this:
Quote:
[root@localhost adil]# gcc cpp/class.cpp -o class
In file included from cpp/class.cpp:2:
cpp/class.h:22:3: warning: no newline at end of file
cpp/class.cpp:7:2: warning: no newline at end of file
/root/tmp/ccpxKxtZ.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/root/tmp/ccpxKxtZ.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >:perator[](unsigned int) const'
/root/tmp/ccpxKxtZ.o(.text+0x9d): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >:perator[](unsigned int) const'
/root/tmp/ccpxKxtZ.o(.text+0xc8): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >:perator[](unsigned int) const'
/root/tmp/ccpxKxtZ.o(.text+0x154): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/root/tmp/ccpxKxtZ.o(.text+0x183): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/root/tmp/ccpxKxtZ.o(.gnu.linkonce.t._ZN1a4drawEv+0x14): In function `a::draw()':
: undefined reference to `std::cout'
/root/tmp/ccpxKxtZ.o(.gnu.linkonce.t._ZN1a4drawEv+0x19): In function `a::draw()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/root/tmp/ccpxKxtZ.o(.gnu.linkonce.t._ZN1a4drawEv+0x22): In function `a::draw()':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)'
/root/tmp/ccpxKxtZ.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
If you leave out the using namespace std, then you will always need to use std::cout.
You can also use #include <iostream.h>, which negates the need to use the using namespace std; but I am sure that it is better practice to use <iostream>, I think that is the proper C++ header as opposes to a C header. I have never used <iostream.h> on linux so am unsure if it is included.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.