C++的Hello World错误

 欧阳俊俊2502921727 发布于 2023-02-10 08:04

我开始学习C++,并尝试运行经典的Hello World程序:

#include 

using namespace std;

int main ()
{
  cout << "Hello, World!";
  return 0;
}

但是当我使用GCC在终端中编译它时,我总是得到错误:

Undefined symbols for architecture x86_64:
  "std::basic_string, std::allocator >::size() const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string, std::allocator > const&)in ccpe3DPY.o
  "std::basic_string, std::allocator >::operator[](unsigned long) const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string, std::allocator > const&)in ccpe3DPY.o
  "std::cout", referenced from:
      _main in ccpe3DPY.o
  "std::basic_ostream >& std::operator<<  >(std::basic_ostream >&, char const*)", referenced from:
      _main in ccpe3DPY.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in ccpe3DPY.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in ccpe3DPY.o
  "___gxx_personality_v0", referenced from:
      Dwarf Exception Unwind Info (__eh_frame) in ccpe3DPY.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

你能告诉我为什么吗?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有