C++ Mac Xcode : Undefined symbols for architecture x86_64:

标签 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)

有人可以帮我吗?

最佳答案

您需要定义一个main 函数。这是第一个被调用以“启动”您的程序的函数。

将此添加到您的文件中:

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

关于C++ Mac Xcode : Undefined symbols for architecture x86_64:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34358715/

相关文章:

ios - CISpotLight 过滤器和零结果

ios - 如何将任意时间转换为 NSDate 以使用 NSDateFormatter 对其进行格式化?

c++ - 我在编译时收到这个 "error: ' string' not declared"

c++ - C++ 中 Dynamic_cast 中的侧投或交叉转换是什么

c++ - mySQl选择查询不显示第一行数据

ios - 带有 Xcode 代码完成的 Objective-C block 属性

swift - Xcode 创建了一个返回错误 "missing setter or instance variable"的 Xib 文件

c++ - C中的蓝牙MAC地址

iphone - 如何验证文本字段中只允许单个小数点的文本字段?

ios - 当我按下后退按钮时出现 Uinavigation 错误