469,951 Members | 2,552 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

undefined reference to std::cout

i program under linux ,and using kdevelop c/c++.
the code follow,
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello, from Win32!" << endl;

return EXIT_SUCCESS;
}
when #gcc -p ty.cpp
error :
root@localhost src]# gcc -p ty.cpp
/tmp/ccsuKY9I.o(.text+0x2a): In function `main':
ty.cpp: undefined reference to `std::cout'
/tmp/ccsuKY9I.o(.text+0x2f):ty.cpp: 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/ccsuKY9I.o(.text+0x3a):ty.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccsuKY9I.o(.text+0x40):ty.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccsuKY9I.o(.text+0x62): In function `__tcf_0':
ty.cpp: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccsuKY9I.o(.text+0x8f): In function `__static_initialization_and_destruction_0(int, int)':
ty.cpp: undefined reference to `std::ios_base::Init::Init()'
/tmp/ccsuKY9I.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

how to solove this problem
think you .i use linux for a few days .
Jun 7 '07 #1
1 10364
Motoma
3,237 Expert 2GB
What version of gcc and kdevelop are you using?

You will probably need to run the ./configure script that kdevelop creates for you.
Jun 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Pmb | last post: by
12 posts views Thread by Minti | last post: by
6 posts views Thread by clilley | last post: by
3 posts views Thread by Jason Heyes | last post: by
6 posts views Thread by Roger | last post: by
5 posts views Thread by wongjoekmeu | last post: by
11 posts views Thread by Adrian | last post: by
58 posts views Thread by Mark Casternoff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.