compiler nightmares

S

Srini

on running this program on some linux versions, it does not compile
bcc test.cpp

what versions?!
---------------------------------------
#include <iostream.h>
using namespace std;
int main()
{
std::cout <<"test";
return 0;
}

---------------------------------

iostream.h is non-standard.

#include <iostream>

There's no std::cout in iostream.h - that's the error...
any suggestions
thanks

Srini
 
R

ravinderthakur

can u plz show the compilation errors.

more over the new c++ standard preferes using
#include <iostream>

to

#include <iostream.h>


thanks
rt
 
S

Srini

bcc test.cpp

Huh?? I hope you meant gcc. And you have to use g++ to compile C++ -
not gcc.

Srini
 
J

John Ratliff

Srini said:
Huh?? I hope you meant gcc. And you have to use g++ to compile C++ -
not gcc.

Srini

Not technically true. You can do gcc test.cpp -lstdc++

But if you use g++, it will add the std c++ library for you.

--John Ratliff

------------------------------ test.cc ------------------------------
#include <iostream>

int main() {
std::cout << "Hello World!\n";

return 0;
}
---------------------------------------------------------------------

gcc is no good:

$ gcc test.cc
/tmp/cc3RNzo4.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/cc3RNzo4.o(.text+0x1e): In function `main':
: undefined reference to `std::basic_ostream<char,
std::char_traits said:
>(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc3RNzo4.o(.text+0x4a): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc3RNzo4.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc3RNzo4.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

but, this works just fine

$ gcc test.cc -lstdc++

Of course, since he didn't add that -lstdc++ line, it's would probably fail.
 
S

Srini

Huh?? I hope you meant gcc. And you have to use g++ to compile C++ -
Not technically true. You can do gcc test.cpp -lstdc++

But if you use g++, it will add the std c++ library for you.

--John Ratliff

I did not know about this. Thanks John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

compiler nightmares 8
difference in header files 11
java calc 6
jsf project 1
linked list error 1
comparing string with character 2
runtime error 4
incompatibility of PGI compiler ? 2

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top