tags:

views:

50

answers:

1

I get the following errors when trying to build a small and simple project that includes <cmath> in 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
...

The error log complains about all the other math functions as well, sin, pow, etc, not just acos. I looked inside cmath source code and it references the globally defined corresponding math functions from math.h, ie ::acos etc. Since the root error complains about the non-existance of ::acos one would assume that math.h can't be found, but a) it exists, and b) I'd get a different error complaining that math.h can't be found.

The source code is as follows:

libraryLAFMath.cp:

#include "libraryLAFMath.h"

libraryLAFMath.h:

#include <cmath>
struct libraryLAFMath {
    void test() {
        double a = std::acos(0);
    }
};

Now, I have another project from an outside source that uses cmath and compiles fine. I tried comparing build settings between these two projects but they are pretty much the same. I am using LLVM GCC 4.2 compiler, but get similar result when using GCC 4.2, so it's not a compiler settings issue I believe.

I'm new to Xcode development and any help is appreciated.

+1  A: 

There is a file I have in my project named Math.h with a capital M, and it seems the compiler gets confused and tries to include Math.h instead of math.h.

andrewz
Edit your question to add more details, don't answer it.
Delan Azabani
@Delan, That sounds like an answer to me, not an additional detail, so no problem...
bdonlan
Hm, I guess. Sorry about that.
Delan Azabani