LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-22-2005, 10:06 PM   #1
philgar
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Rep: Reputation: 0
functions in math.h


I'm trying to compile C using gcc. It doesn't recognize the sqrt() function. I've included the math.h file. Is there something I'm missing here?
 
Old 02-22-2005, 10:40 PM   #2
Ilgar
Senior Member
 
Registered: Jan 2005
Location: Istanbul, Turkey
Distribution: Slackware64 15.0, Slackwarearm 14.2
Posts: 1,157

Rep: Reputation: 237Reputation: 237Reputation: 237
Are you passing the -lm option to gcc (lm = link the math library)?

Last edited by Ilgar; 02-22-2005 at 10:41 PM.
 
Old 02-22-2005, 10:44 PM   #3
philgar
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
no i didn't. that works. thanks for your help.
 
Old 03-27-2005, 05:08 PM   #4
Godsmacker777
Member
 
Registered: Oct 2004
Posts: 52

Rep: Reputation: 15
does this have to be passed for every library you would like to include?

what about the include statements in the .c file?

I have:

Code:
#include <stdio.h>
#include <math.h>
and when compiling (cc main.c), I get:
Code:
In function `main':
: undefined reference to `floor'
Should I de running "cc -lm main.c" ?
How exactly does this work?
 
  


Reply



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
c and math functions davidleroux1 Programming 8 09-14-2006 09:47 PM
Converting php5 socket functions to php3 socket functions mrobertson Programming 0 06-23-2005 09:11 AM
error while accessing math functions in kernel modules dypgrp Programming 0 01-19-2005 09:12 AM
c compiler won't recognize math functions dreamgoat Red Hat 2 08-16-2004 05:45 PM
pointers to functions/member functions champ Programming 2 03-28-2003 06:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:14 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
Open Source Consulting | Domain Registration