I wrote a simple program in linux ubuntu , when I use g ++, there is no error, but when I use gcc , I see this error:
test.c:1:17: fatal error: cmath: No such file or directory #include <cmath>
Note: "in fact, I see this error when compiling the package, I thought it could be due to a gcc library that is not configured for linux, so I wrote a simple program to clearly identify the error and whitout dependency!" therefore, the program must compile with gcc so that I can deal with the main problem. As I understand it, I can use math.h instead of cmath, but packege used cmath! this is a simple program:
#include <cmath> #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int main(){ double sinx = sin(3.14/3); cout<< "sinx= " << sinx; return 0; }
here is cmath pathes:
root@geant4 :/# find -name cmath ./opt/root5.32.00/cint/cint/include/cmath ./app/gcc/4.8.0/include/c++/4.8.0/ext/cmath ./app/gcc/4.8.0/include/c++/4.8.0/cmath ./app/gcc/4.8.0/include/c++/4.8.0/tr1/cmath ./usr/include/boost/compatibility/cpp_c_headers/cmath ./usr/include/boost/tr1/tr1/cmath ./usr/include/c++/4.5/cmath ./usr/include/c++/4.5/tr1_impl/cmath ./usr/include/c++/4.5/tr1/cmath ./usr/include/c++/4.6/cmath ./usr/include/c++/4.6/tr1/cmath ./usr/share/gccxml-0.9/GCC/2.95/cmath ./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath ./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/cmath ./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath ./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath ./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/cmath ./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/include/ext/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/include/c/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/include/c_global/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/include/c_std/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/include/tr1/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/testsuite/26_numerics/headers/cmath ./gcc-build/gcc-4.8.0/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath ./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath ./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/cmath ./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath
and after installing gcc-4.8, I followed this instruction:
root@geant4 :~/Desktop# update-alternatives --install /usr/bin/gcc gcc /app/gcc/4.8.0/bin/gcc 40 --slave /usr/bin/g++ g++ /app/gcc/4.8.0/bin/g++ root@geant4 :~/Desktop#update-alternatives --install /usr/bin/gcc gcc /app/gcc/4.8.0/bin/gcc 60 --slave /usr/bin/g++ g++ /app/gcc/4.8.0/bin/g++ root@geant4 :~/Desktop
to make gcc-4.8 my default gcc.
now
root@geant4 :~/Desktop
I actually wrote the main problem at https://askubuntu.com/questions/309195/cmath-no-such-file-or-directory-include-cmath
Please help me
I do not know what to do.
thanks
source share