免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2002 | 回复: 3
打印 上一主题 下一主题

链接报错: undefined reference to istream::operator<<(c [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-06-11 15:27 |只看该作者 |倒序浏览
1. 我用的是RedHat 9.0

2. gcc 是 3.2.2

3. 代码如下:
   #include <streambuf.h>;
   #include <iostream>;
   
   class AA : public ios
   {
      public :
          virtual int good() { ios::good(); return 1; }
   };

   int main( void)
   {
      class AA oA;

      return 0;
   }

4. g++ -I/usr/include/g++-3 c.cxx -L/usr/lib -lstdc++-3-libc6.2-2-2.10.0
   报错:
/tmp/cckvErv2.o(.gnu.linkonce.t._ZN2AAC1Ev+0x15): In function `AA::AA[in-charge]()':
: undefined reference to `ios::ios[not-in-charge](streambuf*, ostream*)'
/tmp/cckvErv2.o(.gnu.linkonce.t._ZN2AAD1Ev+0x37): In function `AA::~AA [in-charge]()':
: undefined reference to `ios::~ios [not-in-charge]()'
/tmp/cckvErv2.o(.gnu.linkonce.t._ZN2AAD0Ev+0x37): In function `AA::~AA [in-charge deleting]()':
: undefined reference to `ios::~ios [not-in-charge]()'
/tmp/cckvErv2.o(.gnu.linkonce.t._ZN2AA4goodEii+0x1: In function `AA::good(int, int)':
: undefined reference to `ios::good() const'
/tmp/cckvErv2.o(.gnu.linkonce.d._ZTI2AA+0x10): undefined reference to `typeinfo for ios'
collect2: ld returned 1 exit status

5.其中,/usr/lib//tmp/libstdc++-3-libc6.2-2-2.10.0.so 有
  ios::~ios 的定义,这可以用 nm -C /usr/lib//tmp/libstdc++-3-libc6.2-2-2.10.0.so | grep "ios"

6. 请高人指点.

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2004-06-11 15:46 |只看该作者

链接报错: undefined reference to istream::operator<<(c

你这是干嘛呢?
g++ -otest test.cpp就可以了。

论坛徽章:
0
3 [报告]
发表于 2004-06-11 15:52 |只看该作者

链接报错: undefined reference to istream::operator<<(c

是不是忘记namespace了?
加一个using std::ios试试。

论坛徽章:
0
4 [报告]
发表于 2004-06-11 16:04 |只看该作者

链接报错: undefined reference to istream::operator<<(c

thank linux_newbie very much.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP