我在 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/