c ++ Mac Xcode:体系结构x86_64的未定义符号:

时间:2015-12-18 15:17:11

标签: c++ ios xcode macos

我在Mac上的Xcode中用c ++运行以下代码

int fibo(int x)
{
      if (x==1||x==2)
          return 1;
          else
              return fibo(x-1)+fibo(x-2);
}

并且收到此错误无法知道原因。

undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

您需要定义main功能。这是第一个被调用的第一个函数" start"你的计划。

将此内容添加到您的文件中:

int main()
{
    fibo(10);  // calls your function with
}