尝试构建包含<cmath>在 Xcode 中的小而简单的项目时,出现以下错误:
cmath: '*' has not been declared
'::acos' has not been declared
In file included from /Xcode4/Projects/libraryLAFMath/Classes/libraryLAFMath.cp
In file included from /Xcode4/Projects/libraryLAFMath/Classes/libraryLAFMath.h
'::acos' has not been declared in /Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/usr/include/c++/4.2.1/cmath
...
错误日志还抱怨所有其他数学函数sin,pow, 等,而不仅仅是acos. 我查看cmath了源代码,它引用了全局定义的相应数学函数math.h,即::acos等。由于根错误抱怨不存在::acos一个会假设math.h找不到,但是a)它存在,b)我会得到一个不同的错误,抱怨找不到 math.h。
源代码如下:
图书馆LAFMath.cp:
#include "libraryLAFMath.h"
图书馆LAFMath.h:
#include <cmath>
struct libraryLAFMath {
void test() {
double a = std::acos(0);
}
};
现在,我有另一个来自外部来源的项目,可以cmath正常使用和编译。我尝试比较这两个项目之间的构建设置,但它们几乎相同。我正在使用 LLVM GCC 4.2 编译器,但是在使用 GCC 4.2 时得到了类似的结果,所以我相信这不是编译器设置问题。
我是 Xcode 开发的新手,不胜感激。