11 Replies - 7216 Views - Last Post: 09 September 2010 - 12:56 PM Rate Topic: -----

#1 Guest_Guest*


Reputation:

Math.h no such file or directory error

Posted 08 September 2010 - 12:38 PM

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.
Is This A Good Question/Topic? 0

Replies To: Math.h no such file or directory error

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

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

Was This Post Helpful? 0
  • +
  • -

#3 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Math.h no such file or directory error

Posted 08 September 2010 - 01:42 PM

I'm using Windows 7
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

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?
Was This Post Helpful? 0
  • +
  • -

#5 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

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?
Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

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?
Was This Post Helpful? 0
  • +
  • -

#7 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

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.
Was This Post Helpful? 0
  • +
  • -

#8 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

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?

This post has been edited by Oler1s: 08 September 2010 - 02:05 PM

Was This Post Helpful? 0
  • +
  • -

#9 Guest_izic*


Reputation:

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?
Was This Post Helpful? 0

#10 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

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?

This post has been edited by Oler1s: 09 September 2010 - 12:19 PM

Was This Post Helpful? 0
  • +
  • -

#11 Guest_izic*


Reputation:

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;
}


Was This Post Helpful? 0

#12 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

Re: Math.h no such file or directory error

Posted 09 September 2010 - 12:56 PM

If you do:

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1