LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-24-2004, 01:03 AM   #1
pippet
Member
 
Registered: May 2004
Posts: 67

Rep: Reputation: 15
gcc and math.h


i have written a c program in which i invoked cos(x). I compiled it with gcc but failed.
i have tried it with both math.h and tgmath.h but it didn't compile.
I think i have to use some option of gcc.
plz tell me which i the option i have to use.
 
Old 06-24-2004, 01:40 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
The math routines are kept in an external library. If you use any functions included in math.h, then you need to tell gcc to explicitly use that external library.

For example, if your program was named: my_prog.c

Compile it with: gcc -o my_prog -lm my_prog.c

The math library is named libm. You tell gcc to use it with the -lm (lowercase L).
 
1 members found this post helpful.
Old 06-24-2004, 02:35 AM   #3
pippet
Member
 
Registered: May 2004
Posts: 67

Original Poster
Rep: Reputation: 15
It works!!
thank u very much for ur help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
math.h Damicles Programming 9 12-04-2010 05:51 AM
Struggling with Math, need help randyriver10 General 45 08-28-2007 05:27 AM
in need of Math drawing Hjalte Linux - Software 1 10-31-2004 01:53 PM
math and QStings -- help!!! CrazyPilot Programming 0 07-08-2004 04:53 AM
math.h is empty ?? niac Programming 1 11-12-2002 01:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration