首页 文章

无法在我的OSX中编译“hello world”cpp

提问于
浏览
2

我在我的mac上写了一个hello world程序,但是当我编译它时,编译器输出一个错误:

体系结构x86_64的未定义符号:“std :: __ 1 :: locale :: use_facet(std :: __ 1 :: locale :: id&)const”,引用自:std :: __ 1 :: basic_ostream>&std :: __ 1: :__ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7.o“std :: __ 1 :: ios_base :: getloc()const”中,引自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7.o“std :: __ 1 :: basic_string,std :: __ 1 :: allocator> :: __ init(unsigned long,char)“,引自:std :: __ 1 :: ostreambuf_iterator> std :: __ 1 :: __ pad_and_output>(std :: __ 1 :: ostreambuf_iterator>,char const *,char const *,char const *,std :: __ 1 :: ios_base&,char)在endian0-654ab7.o“std :: __ 1 :: basic_string,std :: __ 1 :: allocator> ::〜basic_string()”中,引自: endian0中的std :: __ 1 :: ostreambuf_iterator> std :: __ 1 :: __ pad_and_output>(std :: __ 1 :: ostreambuf_iterator>,char const *,char const *,char const *,std :: __ 1 :: ios_base&,char) -654ab7.o“std: :__ 1 :: basic_ostream> :: sentry :: sentry(std :: __ 1 :: basic_ostream>&)“,引自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1在endian0-654ab7.o“std :: __ 1 :: basic_ostream> :: sentry :: ~sentry()”中引用:: basic_ostream>&,char const *,unsigned long),引用自:std :: __ 1 :: basic_ostream> &std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7.o“std :: __ 1 :: cout”中,引用自:endian0中的_main- 654ab7.o“std :: __ 1 :: ctype :: id”,引自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const * ,unsigned long)在endian0-654ab7.o“std :: __ 1 :: locale :: ~locale()”中,引用自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: endian0-654ab7.o中的__1 :: basic_ostream>&,char const *,unsigned long)“std :: __ 1 :: ios_base :: __ set_badbit_and_consider_rethrow()”,引自:std :: __ 1 :: basic_ostream>&std :: 1 :: __ put_character_sequence>(s在endian0-654ab7.o“std :: __ 1 :: ios_base :: clear(unsigned int)”中的td :: __ 1 :: basic_ostream>&,char const *,unsigned long),引自:std :: __ 1 :: basic_ostream >&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7.o“std :: terminate()”中,引自:endian0中的___clang_call_terminate- 654ab7.o“_ cxa_begin_catch”,引用自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7中 . o ___clang_call_terminate in endian0-654ab7.o“cxa_end_catch”,引自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)在endian0-654ab7.o“ gxx_personality_v0”中,引用自:std :: __ 1 :: basic_ostream>&std :: __ 1 :: __ put_character_sequence>(std :: __ 1 :: basic_ostream>&,char const *,unsigned long)in endian0 -654ab7.o std :: __ 1 :: ostreambuf_iterator> std :: __ 1 :: __ pad_and_output>(s endian0-654ab7.o中的td :: __ 1 :: ostreambuf_iterator>,char const *,char const *,char const *,std :: __ 1 :: ios_base&,char)endian0-654ab7.o中的Dwarf异常展开信息(__eh_frame) ld:找不到架构x86_64 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)

这是该计划:

#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    cout<< "hello world";
    return 0;
}

1 回答

  • 3

    看起来你缺少(无法链接)C运行时库 . 虽然您没有显示用于编译和链接程序的命令行,但应该这样做:

    $ clang++ -o hello hello.cpp
    

相关问题