1 |
ou need to drop the .h. The header files for the new stl and iostream |
2 |
libs have been changed for the new standard. |
3 |
|
4 |
You'll also need to do 1 of 2 things |
5 |
|
6 |
using namespace std; |
7 |
or |
8 |
std::cout << "Hello World" << std::endl; |
9 |
|
10 |
anyway, here are the changes... |
11 |
|
12 |
#include <iostream> |
13 |
using namespace std; |
14 |
int main(){ |
15 |
cout << "Hello World" << endl; |
16 |
return(0); |
17 |
} |
18 |
|
19 |
OR...................... |
20 |
#include <iostream> |
21 |
|
22 |
int main(){ |
23 |
std::cout << "Hello World" << std::endl; |
24 |
return(0); |
25 |
} |
26 |
|
27 |
|
28 |
also gcc doesn't by default link the stl lib to the app. g++ will. |
29 |
|
30 |
That should take care of your problems |
31 |
|
32 |
- Richard Reich |
33 |
|
34 |
On Mon, 2002-08-26 at 10:42, Spider wrote: |
35 |
> |
36 |
> cat hiworld.cpp |
37 |
> #include <iostream.h> |
38 |
> int main(){ |
39 |
> cout << "Hello World" << endl; |
40 |
> return(0); |
41 |
> } |
42 |
> |
43 |
> |
44 |
> Old standard, but should work afaik... |
45 |
> |
46 |
> gcc -dumpversion |
47 |
> 3.2 |
48 |
> |
49 |
> c++ -dumpversion |
50 |
> 3.2 |
51 |
> |
52 |
> |
53 |
> |
54 |
> spider@Darkmere> gcc -o hiworld hiworld.cpp |
55 |
> In file included from /usr/include/g++-v32/backward/iostream.h:31, |
56 |
> from hiworld.cpp:1: |
57 |
> /usr/include/g++-v32/backward/backward_warning.h:32:2: warning: #warning |
58 |
> This file includes at least one deprecated or antiquated header. Please |
59 |
> consider using one of the 32 headers found in section 17.4.1.2 of the |
60 |
> C++ standard. Examples include substituting the <X> header for the <X.h> |
61 |
> header for C++ includes, or <sstream> instead of the deprecated header |
62 |
> <strstream.h>. To disable this warning use -Wno-deprecated. |
63 |
> /tmp/ccKgk3Jj.o: In function `main': |
64 |
> /tmp/ccKgk3Jj.o(.text+0x13): undefined reference to `std::cout' |
65 |
> /tmp/ccKgk3Jj.o(.text+0x20): undefined reference to |
66 |
> `std::basic_ostream<char, std::char_traits<char> >& std::operator<< |
67 |
> <std::char_traits<char> >(std::basic_ostream<char, |
68 |
> std::char_traits<char> >&, char const*)' |
69 |
> /tmp/ccKgk3Jj.o(.text+0x2b): undefined reference to |
70 |
> `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, |
71 |
> std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> |
72 |
> >&)' |
73 |
> /tmp/ccKgk3Jj.o(.text+0x30): undefined reference to |
74 |
> `std::basic_ostream<char, std::char_traits<char> |
75 |
> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& |
76 |
> >(*)(std::basic_ostream<char, std::char_traits<char> >&))' |
77 |
> /tmp/ccKgk3Jj.o: In function |
78 |
> `__static_initialization_and_destruction_0(int, int)': |
79 |
> /tmp/ccKgk3Jj.o(.text+0x59): undefined reference to |
80 |
> `std::ios_base::Init::Init[in-charge]()' |
81 |
> /tmp/ccKgk3Jj.o: In function `__tcf_0': |
82 |
> /tmp/ccKgk3Jj.o(.text+0x8a): undefined reference to |
83 |
> `std::ios_base::Init::~Init [in-charge]()' |
84 |
> /tmp/ccKgk3Jj.o(.eh_frame+0x11): undefined reference to |
85 |
> `__gxx_personality_v0' |
86 |
> collect2: ld returned 1 exit status |
87 |
> |
88 |
> spider@Darkmere> c++ -o hiworld hiworld.cpp |
89 |
> /tmp/dd |
90 |
> In file included from /usr/include/g++-v32/backward/iostream.h:31, |
91 |
> from hiworld.cpp:1: |
92 |
> /usr/include/g++-v32/backward/backward_warning.h:32:2: warning: #warning |
93 |
> This file includes at least one deprecated or antiquated header. Please |
94 |
> consider using one of the 32 headers found in section 17.4.1.2 of the |
95 |
> C++ standard. Examples include substituting the <X> header for the <X.h> |
96 |
> header for C++ includes, or <sstream> instead of the deprecated header |
97 |
> <strstream.h>. To disable this warning use -Wno-deprecated. |
98 |
> |
99 |
> |
100 |
> |
101 |
> |
102 |
> But this works.... . |
103 |
> |
104 |
> Now.. what am I missing here??? |
105 |
> |
106 |
> //Spider |
107 |
> |
108 |
> |
109 |
> -- |
110 |
> begin .signature |
111 |
> This is a .signature virus! Please copy me into your .signature! |
112 |
> See Microsoft KB Article Q265230 for more information. |
113 |
> end |