在下图中的控制台中,您可以看到自动链接可能无法正常工作。我该怎么办?下面是我使用的代码。我还执行了刷新、清理和重建,但错误仍然存在。
/*
* Fibonacci.h
*
* Created on: Apr 2, 2014
* Author: rose
*/
#ifndef FIBONACCI_H_
#define FIBONACCI_H_
unsigned int Fibonacci(unsigned int n);
#endif /* FIBONACCI_H_ */
/*
* Fibonacci.cpp
*
* Created on: Apr 2, 2014
* Author: rose
*/
#include "Fibonacci.h"
unsigned int Fibonacci(unsigned int n)
{
if (n==1) {
return 1;
} else if (n == 0) {
return 0;
}
return Fibonacci(n-2) + Fibonacci(n-1);
}
/*
* main.cpp
*
* Created on: Apr 2, 2014
* Author: rose
*/
#include <iostream>
#include "Fibonacci.h"
int main(int argc, char *argv[])
{
std::cout << "Fibonacci(10) = " << Fibonacci(10) << std::endl;
}
发布于 2014-04-03 06:42:37
这不是链接器的问题,而是编译器的问题。您需要在main.cpp
中包含Fibonacci.h
。
https://stackoverflow.com/questions/22824331
复制相似问题