对于使用Xcode的Mac OS Mavericks,对于clang ++,默认为lib = stdlibc ++?

 柯韵亚 发布于 2023-01-15 09:57

我正在使用Xcode 5.1.1运行MacOS X Mavericks,包括命令行工具.我正在使用Xcode提供的clang ++编译简单的C++程序,版本信息是:Apple LLVM版本5.1(clang-503.0.40)(基于LLVM 3.4svn)

我发现如果我尝试运行以下命令

clang ++ -o hello.out hello.cpp

我收到以下错误:

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

如果我将命令更改为

clang ++ -o hello.out -stdlib = libstdc ++ hello.cpp

我没有得到任何错误.

有没有办法使"-stdlib = libstdc ++"成为clang ++的默认值,或者使用某些配置设置或某些环境变量?另外,仅为了我的信息,为什么我会收到错误?

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