c++Mac Xcode:体系结构x86_64:的未定义符号
c++ Mac Xcode: Undefined symbols for architecture x86_64:
我在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
}
您应该实现main()函数。
在初始化后程序启动时调用主函数具有静态存储持续时间的非本地对象。它是在宿主中执行的程序的指定入口点环境(即具有操作系统)。入口指向独立程序(引导加载程序、操作系统内核等)实现定义。http://en.cppreference.com/w/cpp/language/main_function
#include <iostream> // for std::cout
int fibo(int x)
{
if (x==1||x==2)
return 1;
else
return fibo(x-1)+fibo(x-2);
}
int main()
{
int x = 1;
int result = fibo(x);
std::cout << "Result: " << x; // Printing result
return 0;
}
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- C++ 中 dlsym 的未定义符号
- 仅在 MacOS 上析构函数的未定义符号
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 体系结构x86_64的未定义符号:链接器错误
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 生成文件:体系结构x86_64的未定义符号
- libc++abi未定义符号:_ZTVN10__cxxabif120__si-class_type_infoE
- Xcode"体系结构x86_64的未定义符号"
- 体系结构x86_64的未定义符号:找不到原因
- SWIG链接器:未定义符号:_ZN2cv8fastFreeEPv(cv::fastFree(void*))
- 如何修复架构x86_64的未定义符号,Boost Asio 1.58
- 在Qt5上去静态库:架构的未定义符号x86_64:
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- 监视 SDK 下的未定义符号"__Unwind_SjLj_Unregister"
- 使用 Boost/Python 的未定义符号 - 复杂
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自: