undefined reference to std::cout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • taiyang902
    New Member
    • Jun 2007
    • 1

    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(.tex t+0x2a): In function `main':
    ty.cpp: undefined reference to `std::cout'
    /tmp/ccsuKY9I.o(.tex t+0x2f):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >& std::operator<< <std::char_trai ts<char> >(std::basic_os tream<char, std::char_trait s<char> >&, char const*)'
    /tmp/ccsuKY9I.o(.tex t+0x3a):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >& std::endl<char, std::char_trait s<char> >(std::basic_os tream<char, std::char_trait s<char> >&)'
    /tmp/ccsuKY9I.o(.tex t+0x40):ty.cpp: undefined reference to `std::basic_ost ream<char, std::char_trait s<char> >::operator<<(s td::basic_ostre am<char, std::char_trait s<char> >& (*)(std::basic_ ostream<char, std::char_trait s<char> >&))'
    /tmp/ccsuKY9I.o(.tex t+0x62): In function `__tcf_0':
    ty.cpp: undefined reference to `std::ios_base: :Init::~Init()'
    /tmp/ccsuKY9I.o(.tex t+0x8f): In function `__static_initi alization_and_d estruction_0(in t, int)':
    ty.cpp: undefined reference to `std::ios_base: :Init::Init()'
    /tmp/ccsuKY9I.o(.eh_ frame+0x11): undefined reference to `__gxx_personal ity_v0'
    collect2: ld returned 1 exit status

    how to solove this problem
    think you .i use linux for a few days .
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    What version of gcc and kdevelop are you using?

    You will probably need to run the ./configure script that kdevelop creates for you.

    Comment

    Working...