lang iostream-找不到符号 [英] clang iostream - symbol not found

查看:136
本文介绍了lang iostream-找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图让clang编译器正常工作..我自然的首选程序是以下极其复杂的代码:

So I'm trying to get the clang compiler to work.. my natural first choice of program was the following extremely complex code:

#include <iostream>
using std::cout;    using std::endl;
/* hello world.cpp */
int main()
{
    cout << "Hello, world!" << endl;
    return 0;
}

在命令行上,我做了:clang helloworld.cpp,并且得到了以下不错的错误:

On the command line I did: clang helloworld.cpp and I get the following nice error:

Undefined symbols for architecture x86_64:
  "std::ios_base::Init::~Init()", referenced from:
      ___cxx_global_var_init in cc-4iziZq.o
  "std::ios_base::Init::Init()", referenced from:
      ___cxx_global_var_init in cc-4iziZq.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in cc-4iziZq.o
  "std::cout", referenced from:
      _main in cc-4iziZq.o
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
      _main in cc-4iziZq.o
  "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
      _main in cc-4iziZq.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

怎么了? 谢谢! -kstruct

What is wrong? Thanks! -kstruct

推荐答案

clang是C编译器.您需要使用clang++或使用-x c++标志.

clang is a C compiler. You need to use clang++ or use the -x c++ flag.

这篇关于lang iostream-找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆