For some reason, whenever I add the FLTK directory to my include path, I get a bunch of errors from cmath. I am using GCC version 4.2. Here is a sample program and the build output:
main.cpp
#include <cmath>
int main()
{
return 0;
}
**** Build of configuration Debug for project CMath Test ****
make -k all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/FL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
In file included from ../main.cpp:1:
/usr/include/c++/4.2/cmath:100: error: ‘::acos’ has not been declared
/usr/include/c++/4.2/cmath:116: error: ‘::asin’ has not been declared
/usr/include/c++/4.2/cmath:132: error: ‘::atan’ has not been declared
/usr/include/c++/4.2/cmath:148: error: ‘::atan2’ has not been declared
/usr/include/c++/4.2/cmath:165: error: ‘::ceil’ has not been declared
/usr/include/c++/4.2/cmath:181: error: ‘::cos’ has not been declared
/usr/include/c++/4.2/cmath:197: error: ‘::cosh’ has not been declared
/usr/include/c++/4.2/cmath:213: error: ‘::exp’ has not been declared
/usr/include/c++/4.2/cmath:229: error: ‘::fabs’ has not been declared
/usr/include/c++/4.2/cmath:245: error: ‘::floor’ has not been declared
/usr/include/c++/4.2/cmath:261: error: ‘::fmod’ has not been declared
/usr/include/c++/4.2/cmath:271: error: ‘::frexp’ has not been declared
/usr/include/c++/4.2/cmath:287: error: ‘::ldexp’ has not been declared
/usr/include/c++/4.2/cmath:303: error: ‘::log’ has not been declared
/usr/include/c++/4.2/cmath:319: error: ‘::log10’ has not been declared
/usr/include/c++/4.2/cmath:335: error: ‘::modf’ has not been declared
/usr/include/c++/4.2/cmath:354: error: ‘::pow’ has not been declared
/usr/include/c++/4.2/cmath:376: error: ‘::sin’ has not been declared
/usr/include/c++/4.2/cmath:392: error: ‘::sinh’ has not been declared
/usr/include/c++/4.2/cmath:408: error: ‘::sqrt’ has not been declared
/usr/include/c++/4.2/cmath:424: error: ‘::tan’ has not been declared
/usr/include/c++/4.2/cmath:440: error: ‘::tanh’ has not been declared
make: *** [main.o] Error 1
make: Target `all' not remade because of errors.
Build complete for project CMath Test
g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
Can anyone tell me what's wrong? Thanks!
Pure speculation, but is there a 'math.h' header in /usr/include/FL
by any chance? Or is there some other header in there that is included by cmath
?
[...a little time passes...]
Still speculation, but given the comment "Yes, there is - what's going on?", I will speculate that there is no 'math.h' header in /usr/include - because if there was GCC (G++) would normally pick up from the same place as ''. So, I would check the installed software - headers under /usr/include - for sanity.
[...a little more time passes...]
Ah, well...it seems that the problem is that there are two math.h
headers, and the compiler is picking the wrong one.
There are a couple of tricks you can try. First, perhaps, is to check the documentation of FLTK: are you supposed to use <FL/header.h>
or just <header.h>
to access its headers? If you are supposed to use the version with the sub-directory, then you don't need to add -I/usr/include/FL
to the compilation command line; the references to <FL/header.h>
will be handled automatically (by looking for /usr/include/FL/header.h
when scanning /usr/include
- just like <sys/types.h>
is found under /usr/include
).
If that isn't part of the answer, then you can try using the flags:
-I/usr/include -I/usr/include/FL
This says "search /usr/include
before searching /usr/include/FL
(and then search /usr/include
again after searching /usr/include/FL
)". That should solve the immediate problem - however it might cause trouble with whatever is supposed to include /usr/include/FL/math.h
. This is definitely not as reliable as the first option.