用gcc编译c++程序时出现问题 - 爱问答

(爱问答)

用gcc编译c++程序时出现问题

C:UsersDell>gcc 5-1.cpp -o 5-1C:UsersDellAppDataLocalTempccLyfQvy.o:5-1.cpp:(.text+0x20): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'

C:UsersDellAppDataLocalTempccLyfQvy.o:5-1.cpp:(.text+0x2e): undefined reference to `std::cin'

上面是编译后一长串中的前两行,用gcc编译c程序时还没有出现过问题,下面是编译的c++程序

#include<iostream>

#include<string>

#include<sstream>

using namespace std;

int main()

string line;

 while(getline(cin, line))

 {  int x, sum = 0; 

 stringstream ss(line);

  while(ss >> x) sum += x;

  cout << sum << " "; }

return 0;

}

你用gcc编译C++的程序,命令行不能用gcc

要用g++的,以下是完整命令

g++ 5-1.cpp -o 5-1

下一篇:想要进行无人机编队控制,有经验的来说说怎么实现?

上一篇:除了vbs,bat,txt,cmd,vbe还有什么和这些一样的

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?