compile problem

L

luke.yolanda

I write a simple problem ,as:

******************************
//temp.cpp
#include<iostream.h>

int main(void){
cout<<"123131231";
return 0;
}
*****************************


and when I type "gcc -o temp temp.cpp", it shows:

*******************************
In file included from /usr/include/c++/4.0.2/backward/iostream.h:31,
from temp.cpp:1:
/usr/include/c++/4.0.2/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <iostream> instead of
the deprecated header <iostream.h>. To disable this warning use
-Wno-deprecated.
/tmp/cc2wKN3t.o: In function `main':
temp.cpp:(.text+0x25): undefined reference to `std::cout'
temp.cpp:(.text+0x2a): undefined reference to `std::basic_ostream<char,
std::char_traits said:
(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc2wKN3t.o: In function `__tcf_0':
temp.cpp:(.text+0x47): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/cc2wKN3t.o: In function
`__static_initialization_and_destruction_0(int, int)':
temp.cpp:(.text+0x74): undefined reference to
`std::ios_base::Init::Init()'
/tmp/cc2wKN3t.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

*******************************

Could anyone tell me what teh problem is?
 
R

Robert Gamble

I write a simple problem ,as:

******************************
//temp.cpp
#include<iostream.h>

Stop right there. The space goes *after* the comma.
And oh yeah, we don't discuss that C++ stuff here, different language,
different group, try comp.lang.c++.

Robert Gamble
 
K

Keith Thompson

I write a simple problem ,as:

******************************
//temp.cpp
#include<iostream.h>

int main(void){
cout<<"123131231";
return 0;
}
*****************************

This is C++, not C. I'd tell you to post to comp.lang.c++, but ...
and when I type "gcc -o temp temp.cpp", it shows:

******************************* [snip]
/tmp/cc2wKN3t.o: In function `main':
temp.cpp:(.text+0x25): undefined reference to `std::cout'
[snip]

it's a problem with your compilation environment, not with the
language. Try gnu.gcc.help.
 
S

santosh

I write a simple problem ,as:

******************************
//temp.cpp
#include<iostream.h>

int main(void){
cout<<"123131231";
return 0;
}
*****************************


and when I type "gcc -o temp temp.cpp", it shows:

Just a wild guess, but why not try with the 'g++' command instead.
(Under DOS i.e. DJGPP, it is 'gpp')

For further C++ questions, please post to a C++ newsgroup like
comp.lang.c++ or alt.comp.lang.learn.c-c++ etc.
 
J

John Bode

Cross-posted to comp.lang.c++, followups set to comp.lang.c++.

I write a simple problem ,as:

******************************
//temp.cpp
#include<iostream.h>

int main(void){
cout<<"123131231";
return 0;
}
*****************************


and when I type "gcc -o temp temp.cpp", it shows:

*******************************
In file included from /usr/include/c++/4.0.2/backward/iostream.h:31,
from temp.cpp:1:
/usr/include/c++/4.0.2/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <iostream> instead of
the deprecated header <iostream.h>. To disable this warning use
-Wno-deprecated.
/tmp/cc2wKN3t.o: In function `main':
temp.cpp:(.text+0x25): undefined reference to `std::cout'
temp.cpp:(.text+0x2a): undefined reference to `std::basic_ostream<char,

/tmp/cc2wKN3t.o: In function `__tcf_0':
temp.cpp:(.text+0x47): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/cc2wKN3t.o: In function
`__static_initialization_and_destruction_0(int, int)':
temp.cpp:(.text+0x74): undefined reference to
`std::ios_base::Init::Init()'
/tmp/cc2wKN3t.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

*******************************

Could anyone tell me what teh problem is?

Change iostream.h to just iostream, and either change cout to std::cout
or use a using clause:

#include <iostream>

int main(void)
{
std::cout << "123131231" << std::endl; // wouldn't hurt to throw an
EOL in here
return 0;
}

or

#include <iostream>

using std::cout;
using std::endl;

int main(void)
{
cout << "123131231" << endl;
}
 

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


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top