469,934 Members | 1,931 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

iostream error.

Hi All,

I am executing simple hello world program. But, getting compile time
errors.
What is the problem here?

prasad@D-T11673A:~/programs/c> cat bst.cpp
#include<iostream>

using namespace std;

int main ()
{
cout << "Hello World." ;
return 0 ;

}

prasad@D-T11673A:~/programs/c> gcc bst.cpp
/tmp/ccrmoRpD.o: In function `main':
bst.cpp:(.text+0x25): undefined reference to `std::cout'
bst.cpp:(.text+0x2a): 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/ccrmoRpD.o: In function `__tcf_0':
bst.cpp:(.text+0x47): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/ccrmoRpD.o: In function
`__static_initialization_and_destruction_0(int, int)':
bst.cpp:(.text+0x74): undefined reference to
`std::ios_base::Init::Init()'
/tmp/ccrmoRpD.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

prasad@D-T11673A:~/programs/c> echo $?
1

Thanks & regards,
Prasad

May 4 '06 #1
2 2679
Prasad wrote:
Hi All,

I am executing simple hello world program. But, getting compile time
errors.
What is the problem here?

prasad@D-T11673A:~/programs/c> cat bst.cpp
#include<iostream>

using namespace std;

int main ()
{
cout << "Hello World." ;
return 0 ;

}

prasad@D-T11673A:~/programs/c> gcc bst.cpp


Use g++.

--
Ian Collins.
May 4 '06 #2
Prasad wrote:
Hi All,

I am executing simple hello world program. But, getting compile time
errors.
What is the problem here?

prasad@D-T11673A:~/programs/c> cat bst.cpp
#include<iostream>

using namespace std;

int main ()
{
cout << "Hello World." ;
return 0 ;

}

prasad@D-T11673A:~/programs/c> gcc bst.cpp
/tmp/ccrmoRpD.o: In function `main':
bst.cpp:(.text+0x25): undefined reference to `std::cout'
bst.cpp:(.text+0x2a): 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/ccrmoRpD.o: In function `__tcf_0':
bst.cpp:(.text+0x47): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/ccrmoRpD.o: In function
`__static_initialization_and_destruction_0(int, int)':
bst.cpp:(.text+0x74): undefined reference to
`std::ios_base::Init::Init()'
/tmp/ccrmoRpD.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

prasad@D-T11673A:~/programs/c> echo $?
1

Thanks & regards,
Prasad


Use:

gcc bst.cpp -lstdc++

or:

g++ bst.cpp

Dave.

May 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by John Tiger | last post: by
13 posts views Thread by David Rubin | last post: by
1 post views Thread by ya man | last post: by
8 posts views Thread by mmu2643 | last post: by
2 posts views Thread by Chris Jones | last post: by
reply views Thread by Herman.Schultz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.