本文介绍了使用c ++ 11启用clang编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有以下 test.cpp
:
#include <iostream>
int main() {
int a{};
std::cout << "TEST" << std::endl;
}
使用最新的GCC(4.8.0) g ++ test.cpp -std = c ++ 11
(gcc也失败),文件编译。尝试使用最新的clang
When build with the latest GCC (4.8.0) g++ test.cpp -std=c++11
(gcc also fails), the file compiles. Trying to compile with the latest clang
clang version 3.4 (trunk 182322)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
构建失败:
clang test.cpp -std=c++11
Undefined symbols for architecture x86_64:
"std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
_main in test-NcubkF.o
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in test-NcubkF.o
"std::ios_base::Init::~Init()", referenced from:
___cxx_global_var_init in test-NcubkF.o
"std::cout", referenced from:
_main in test-NcubkF.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 test-NcubkF.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 test-NcubkF.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
(或 gcc
)可以在C + +11模式?
What can be done for clang
(or gcc
) to work in C++11 mode?
推荐答案
clang
使用 clang ++
。
clang++ test.cpp -std=c++11
这篇关于使用c ++ 11启用clang编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!