Fatal error math h no such file or directory

Forum rules There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section. Before you post please read how to get help. Topics in this forum are automatically closed 6 months after creation.

Forum rules
There are no such things as «stupid» questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help. Topics in this forum are automatically closed 6 months after creation.

ashtongj

SOLVED: Finding c math library

I’m trying to compile a c program on a newly-installed Cinnamon 16. I didn’t do anything special to install any development tools.

The function being compiled uses math so includes the math library:

But when I use a make file that issues this comilation command:

Code: Select all

gcc -c -pedantic -Wall -W -O -lm -o iauA2af.o a2af.c

I get this error message:

Code: Select all

In file included from a2af.c:1:0:
sofa.h:22:18: fatal error: math.h: No such file or directory
 #include "math.h"
                  ^
compilation terminated.
make: *** [iauA2af.o] Error 1

I am guessing that either the math library header files is in some package I haven’t installed, or that some search path needs to be modified to find the include file. Suggestions?

Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.

Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.

ashtongj

Re: Finding c math library

Post

by ashtongj » Mon Mar 03, 2014 1:45 pm

Changing «math.h» to <math.h> gave the same results (except, of course, the error message contained angle brackets instead of quote marks).

ashtongj

Re: Finding c math library

Post

by ashtongj » Mon Mar 03, 2014 2:04 pm

On another forum I found a poster with a similar problem who issued this command:

Code: Select all

sudo apt-get install build-essintial

I tried that and it solved my problem.

vodamet

0 / 0 / 0

Регистрация: 30.05.2019

Сообщений: 10

1

03.06.2019, 20:04. Показов 2882. Ответов 4

Метки нет (Все метки)


code blocks. помогите исправить единственную ошибку в коде:
ошибка в первой строке include math

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <math>
#include <iostream>
#include <windows>
#include <locale>
 
void main (void)
{
    setlocale(LC_ALL, "Russian");
    SetConsoleOutputCP(1251); //1251
    SetConsoleCP(1251);
    setlocale(LC_CTYPE, "rus");
 
system("color 0F");
 
double x,z;
cout<<"Input X = "; cin>>x;
cout<<"Input Z = "; cin>>z;
double b = x*(atan(z)+exp(-(x+3)));
cout<<"Result A = "<<b;
double a = (sqrt(abs(x - 1.0)) - sqrt(abs(y))) / (1.0 + x * x / 2.0 + y * y / 4.0);
double b = x * (atan(z) + exp(-(x + 3)));
 
cout<<endl<<endl;
system("pause");
 
return;
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



551 / 875 / 144

Регистрация: 10.08.2015

Сообщений: 4,513

03.06.2019, 20:06

2

сmath



0



0 / 0 / 0

Регистрация: 30.05.2019

Сообщений: 10

03.06.2019, 20:08

 [ТС]

3

когда ставлю cmath. то ошибку перекидывает на windows



0



551 / 875 / 144

Регистрация: 10.08.2015

Сообщений: 4,513

03.06.2019, 20:10

4

а если открыть учебник по с++?



1



0 / 0 / 0

Регистрация: 30.05.2019

Сообщений: 10

03.06.2019, 20:17

 [ТС]

5

закрыто.



0



I downloaded and try to installed the package «wfconvert» from this link . but I got some error.

here what I did:

  1. copy the wfconvert folder in root «/»
  2. cd /wfconvert/build/

    root@geant4:/wfconvert/build# cmake ..
    
    -- Current revision : 65 modified on 2013-01-16 22:14:53 +0330 (Wed, 16 Jan 2013)  
    -- Found mpi.h and libraries. Check for working mpi compiler  
    -- MPI is disabled  
    -- Failed to link LAPACK, BLAS, ATLAS libraries with environments. Going to search standard paths.  
    -- LAPACK_LIBRARIES=/usr/lib/liblapack.so  
    -- BLAS_LIBRARIES=/usr/lib/libblas.so  
    -- CXX compiler flags:  -g -O3 -ftemplate-depth-60 -Drestrict=__restrict__ -funroll-all-loops   -finline-limit=1000 -Wno-deprecated  -mmmx -msse -msse2 -msse3 -fopenmp  
    -- CC  compiler flags:  -O3 -Drestrict=__restrict__ -funroll-all-loops   -finline-limit=1000 -std=gnu99 -fomit-frame-pointer  -mmmx -msse -msse2 -msse3  
    -- LIBXML2_INCLUDE_DIR=/usr/include/libxml2  
    -- LIBXML2_LIBRARIES=/usr/lib/libxml2.so  
    -- HDF5_INCLUDE_DIR=/usr/include  
    -- HDF5_LIBRARIES=/usr/lib/libhdf5.so  
    -- FFTW_INCLUDE_DIR=/usr/include  
    -- FFTW_LIBRARIES=/usr/lib/libfftw3.so  
    -- Ready to build qmcpack  
    -- Configuring done  
    -- Generating done  
    -- Build files have been written to: /wfconvert/build  
    
  3. make command

    root@geant4:/wfconvert/build# make
    
    [  1%] Building C object src/einspline/CMakeFiles/einspline.dir/bspline_create.c.o  
    In file included from /wfconvert/src/einspline/bspline_base.h:24:0,  
             from /wfconvert/src/einspline/bspline_create.h:24,  
             from /wfconvert/src/einspline/bspline_create.c:21:  
    /wfconvert/build/src/Common/config.h:65:17: fatal error: cmath: No such file or directory  
     #include <cmath> 
             ^
    compilation terminated.    
    make[2]: *** [src/einspline/CMakeFiles/einspline.dir/bspline_create.c.o] Error 1  
    make[1]: *** [src/einspline/CMakeFiles/einspline.dir/all] Error 2  
    make: *** [all] Error 2  
    

I don`t know what to do!
here is my cmath file list:

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

root@geant4:/# uname -a
Linux geant4 3.0.0-32-generic-pae #51-Ubuntu SMP Thu Mar 21 16:09:48 UTC 2013 i686 i686 i386 GNU/Linux

Please help me.

Ravexina's user avatar

Ravexina

53k23 gold badges151 silver badges176 bronze badges

asked Jun 17, 2013 at 11:04

alireza yousefi's user avatar

2

I would suspect corrupt installation of development tools or something like that. First thing I would do is re install build package

sudo apt-get purge build-essential
sudo apt-get install build-essential

If the problem still persists post it back

Just curious: How did you install GCC 4.8? I have 13.04 and it have 4.7.3
So that might be an issue if was not done properly!

answered Jun 17, 2013 at 11:09

Stefano Mtangoo's user avatar

Stefano MtangooStefano Mtangoo

2,7602 gold badges28 silver badges39 bronze badges

4

With gcc it looks this:

gcc example.c -o example -lm   

for more precise compiling (with debugging output in case of failures) you do this:

gcc -ggdb -Wall example.c -o example -lm

lm is here the linking with the math-library of gcc (there is #include math.h at the beginning of example.c).

Ravexina's user avatar

Ravexina

53k23 gold badges151 silver badges176 bronze badges

answered Jun 18, 2013 at 17:21

dschinn1001's user avatar

dschinn1001dschinn1001

3,6936 gold badges26 silver badges38 bronze badges

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error mapping iso please check if file is present and defragmented
  • Fatal error mapiexceptionshutoffquotaexceeded has occurred
  • Fatal error malloc h file not found
  • Fatal error lua h no such file or directory
  • Fatal error loading vertex shader custom weapon vs30 00000000 что делать

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии