在unix下编译C++程序,怎么总有错误?

在unix下编译c++和在windows下编译有什么不一样?
文件名为try.cpp
#include <iostream.h>
int main()
{
cout<<"hello world!\r\n";
}
命令: cc try.cpp
错误:--------------------
[root@localhost usr]# cc try.cpp
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
from try.cpp:1:
/usr/include/c++/3.2.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 <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
try.cpp:5:2: warning: no newline at end of file
/tmp/ccAaRAvY.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/ccAaRAvY.o(.text+0x1e): In function `main':
: 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/ccAaRAvY.o(.text+0x4a): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Initin-charge'
/tmp/ccAaRAvY.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init in-charge'
/tmp/ccAaRAvY.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

259 浏览 3 回复
  std   to   in   undefined   tmp  

回复

    or <sstream> instead of the deprecated header <strstream.h>.
    用<iostream>,跟windows下是一样的,这是最新的C++版本
    VS2005里也是这样的
    #include <iostream>
    using namespace std;//另外还要添加一句,才可以打印输出
    int main()
    {
    .....
    }

    黎涟珴

    请使用标准C++,即:
    #include <iostream>
    using namespace std;
    int main()
    {
    cout<<"hello world!\r\n";
    }

    小邦

    同意楼上所说!`

    段群思

相关信息

Exception in thread "main" java.lang.NoXuchMethodError: main

Exception in thread "main" java.lang.NoXuchMethodError: main 运行JAVA程序时,出现上述语句是什么意思。 程序如下: /\* This class uses API introduced in 1.1. \*/ import java.util.Locale; public class...

38 浏览 3 回复   main   运行   没有   java   public  

转换的int为std :: string [复制]

> <p> <strong>可能重复: STRONG&gt;结果 [ INT到为std :: string?](http://stackoverflow.com/questions/893670/int-to-stdstring) P&gt; 块引用&gt; <p>您如何转换INT至为std :: string? P&gt; > </p></strong></p></blockquote>

48 浏览 1 回复   gt   string   std   int   转换  

the difference between structure and class in C++

there are different type of data in structure such as int long double and so on we can also use private or public protected in it;but we can use all of them in one class!!what is the difference between...

67 浏览 4 回复   the   in   and   of   class  

c中 像int main() ,main()前有int是什么意思?

如题,谢谢大家 希望大家能详细点,我只见过main()前什么也没的 基础很差

76 浏览 7 回复   int   返回   程序   main   执行  

大家帮我看看~~写的这个C程序老是在连接时显示Undefined symbol '_main' in module COS

打印99乘法表 \#include<stdio.h> mian() { int m,n,j; for(m=1;m<=9;m++) { for(n=1;n<=9;n++) printf("%d\*%d=%-4d",m,n,m\*n); printf("\\n"); } }

39 浏览 3 回复   for   main   int   printf   #39