我需要一些帮助。 最近我试图学习一些编程,并且遇到了一些问题,但他们都解决了。 除此之外。 我知道它已被回答了很多次,但我从未找到针对我的特定案例的解决方案。 我使用的Xcode 4.5.2 V.这里 是程序:架构x86_64的未定义符号Xcode Mac
int add(int x, int y);
int main()
using namespace std;
cout << "3 + 4 + 5 = " << add(3, 4) << endl;
return 0;
}
int add(int x, int y, int z)
return x + y + z;
}
它给我这个错误:
Undefined symbols for architecture x86_64: "add(int, int)", referenced from: _main in main.o (maybe you meant: __Z3addiii) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我不知道该怎么做。
我一直在关注这个教程:
http://www.learncpp.com/cpp-tutorial/17-forward-declarations/
测验下的第五个节目是这一个。
感谢 Lemonizer
我意识到这一点,你看这里不是问题。 该程序不应该工作,它是为了学习的目的,它没有,以便你可以找到问题,(你做到了:D),但这个错误仍然不是它的一部分。 谢谢您的(非常!)快速回答,但不幸的不是我需要的那个:( – Lemonizer 2013-02-21 21:59:37
@Lemonizer:呃...什么?根据你的链接错误,这是*正是*什么是错的。你的前向声明是'int add(int x,int y);'和你的函数调用是'add(3,4,5)'然后呢?有几种方法可以解决这个错误,但是我的答案是“The需要匹配100%“是确切的解决方案,你如何让它们匹配100%取决于你 – Cornstalks 2013-02-21 22:04:20
你好再次 如果你在后面的帖子中看到链接,你可以看到作者也提到它将不会链接,但他没有提到任何''更高级别的错误''这不仅仅是一个红色!,它有它自己的页面:S – Lemonizer 2013-02-21 22:07:11