LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1373|回复: 11

RH9.0下的 C++ 编译不过去是怎么回事?

[复制链接]
发表于 2003-4-14 19:57:01 | 显示全部楼层 |阅读模式
连这样简单的代码都过不去:

#include<iostream.h>
int main()
{
        cout<<"welcome to gcc!"<<endl;
        return 0;
}

我用的是一般用户权限, 在高级管理员权限下好像能通过
不过下面加了一堆警告:

In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
                 from hello.cc: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.

我用的命令是:
$ g++ hello.cpp

哪位大侠能告诉我是怎么回事
谢谢!
谢谢!
发表于 2003-4-14 20:03:17 | 显示全部楼层
  1. #include<iostream>
  2. using namespace
  3. int main()
  4. {
  5.     cout<<"welcome to gcc!"<<"\n";
  6.     return 0;
  7. }
复制代码


这样试试
 楼主| 发表于 2003-4-14 20:08:50 | 显示全部楼层
我试了一下  还是不行
有没有别的办法?
发表于 2003-4-15 00:20:45 | 显示全部楼层
在论坛中搜索一下,不久前有人刚刚问过同样的问题。
发表于 2003-4-15 06:13:18 | 显示全部楼层
#include<iostream>
int main()
{
    std::cout<<"welcome to gcc!"<<"\n";
    return 0;
}
这是新的gcc必须指定std。你看下
 楼主| 发表于 2003-4-15 10:56:53 | 显示全部楼层
成功了
thank you
发表于 2003-5-10 19:11:17 | 显示全部楼层

我编译的时候出来这个问题

/tmp/cc9GLCXp.o(.text+0x21): In function `main':
: undefined reference to `std::cout'
/tmp/cc9GLCXp.o(.text+0x26): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc9GLCXp.o(.text+0x2f): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc9GLCXp.o(.text+0x5c): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc9GLCXp.o(.text+0x8b): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc9GLCXp.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
发表于 2003-5-10 19:12:44 | 显示全部楼层

我的gcc版本

3.2
发表于 2003-5-13 16:46:37 | 显示全部楼层
应该是连接没弄好,我刚才用 gcc 试了可以。

试试
gcc test.cxx -l stdc++ -o test
发表于 2003-5-13 19:18:09 | 显示全部楼层
#include<iostream>
using namespace std;
int main()
{
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表