I'm trying to compile a C program in putty using the <math.h> header. I compile the program with gcc timed.c -o timed -lm but I still keep getting this error.
Math.h no such file or directory error
Page 1 of 111 Replies - 3952 Views - Last Post: 09 September 2010 - 12:56 PM
#1 Guest_Guest*
Math.h no such file or directory error
Posted 08 September 2010 - 12:38 PM
Replies To: Math.h no such file or directory error
#2
Re: Math.h no such file or directory error
Posted 08 September 2010 - 12:42 PM
What OS? Expecting this is a *nix variant, look in /usr/include. Is it there? I believe it should be in there. If so, you could try
gcc -I/usr/include timed.c -o timed -lm
#3
Re: Math.h no such file or directory error
Posted 08 September 2010 - 01:42 PM
I'm using Windows 7
#4
Re: Math.h no such file or directory error
Posted 08 September 2010 - 01:44 PM
What are you using that supplies gcc as the compiler? What is your development environment?
#5
Re: Math.h no such file or directory error
Posted 08 September 2010 - 01:45 PM
I'm not sure what you mean. How do I find that out?
#6
Re: Math.h no such file or directory error
Posted 08 September 2010 - 01:51 PM
Essentially, what did you download to get gcc on your computer?
#7
Re: Math.h no such file or directory error
Posted 08 September 2010 - 01:52 PM
Oh, I didn't download it. I'm using a computer at my school so I wouldn't know.
#8
Re: Math.h no such file or directory error
Posted 08 September 2010 - 02:04 PM
To clarify, we aren't interested in the local computer, as in the one you are sitting at and typing. We are interested in the computer you connect to. If this is a computer at your school, or in other words, you don't control it, you need to talk to whoever administers those machines.
Here's a way to get more information, to ensure if the problem is on your account or the administration of the machine. We need to find out where gcc is searching for headers. Type gcc -v -c timed.c
You should get a whole dump of output. If you look carefully through the output, you'll see something like #include <...> search starts here: Then you'll see some paths listed. Then you'll see End of search list.
Can you tell us what those listed paths are?
Here's a way to get more information, to ensure if the problem is on your account or the administration of the machine. We need to find out where gcc is searching for headers. Type gcc -v -c timed.c
You should get a whole dump of output. If you look carefully through the output, you'll see something like #include <...> search starts here: Then you'll see some paths listed. Then you'll see End of search list.
Can you tell us what those listed paths are?
This post has been edited by Oler1s: 08 September 2010 - 02:05 PM
#9 Guest_izic*
Re: Math.h no such file or directory error
Posted 09 September 2010 - 12:08 PM
/usr/sfw/include
/usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/include
/usr/include
End of search list.
GNU C version 3.4.3 (csl-sol210-3_4-branch+sol_rpath) (i386-pc-solaris2.10)
compiled by GNU C version 3.4.3 (csl-sol210-3_4-branch+sol_rpath).
I think you mean the first three in bold but I saw some other stuff that had paths in it. Is this what you mean?
/usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/include
/usr/include
End of search list.
GNU C version 3.4.3 (csl-sol210-3_4-branch+sol_rpath) (i386-pc-solaris2.10)
compiled by GNU C version 3.4.3 (csl-sol210-3_4-branch+sol_rpath).
I think you mean the first three in bold but I saw some other stuff that had paths in it. Is this what you mean?
#10
Re: Math.h no such file or directory error
Posted 09 September 2010 - 12:18 PM
You got what I wanted to see. The search paths look sane.
A thought, to confirm something very important. Case sensitivity matters. So are you certain you have #include <math.h>, and not <math.H> or <Math.H> or <MATH.H> or something else?
A thought, to confirm something very important. Case sensitivity matters. So are you certain you have #include <math.h>, and not <math.H> or <Math.H> or <MATH.H> or something else?
This post has been edited by Oler1s: 09 September 2010 - 12:19 PM
#11 Guest_izic*
Re: Math.h no such file or directory error
Posted 09 September 2010 - 12:30 PM
Yeah I'm pretty positive. This my code below. I use gcc timed.c -o timed -lm to compile it.
#include<stdio.h>
#include<math.h>
int main(void)
{
int i;
for(i=0; i<10000; ++i)
printf("The cosine of pi/%d is %f. \n", i, cos(3.1415/i));
return 0;
}
#12
Re: Math.h no such file or directory error
Posted 09 September 2010 - 12:56 PM
If you do:
is the file found?
I would consider talking to the lab tech, or your TA, or your professor about why it's not working. This is a job for the people who get paid.
cd /usr/include find . -name math.h -print
is the file found?
I would consider talking to the lab tech, or your TA, or your professor about why it's not working. This is a job for the people who get paid.
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote








|