LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
LinkBack Search this Thread
Old 10-19-2008, 01:11 AM   #1
warun
Member
 
Registered: Aug 2007
Posts: 39

Rep: Reputation: 15
math.h error


hello everyone,

i am using slackware 12.1. i get this error while compiling c/c++ programs with math header.

/tmp/ccqG44Ak.o: In function `main':
try.c.text+0x21): undefined reference to `cos'
collect2: ld returned 1 exit status

it worked fine in slackware 12.0. why is it so and is there any change in slackware 12.1 that i should be aware of?

thanks in advance....
 
Old 10-19-2008, 01:25 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,858
Blog Entries: 1

Rep: Reputation: Disabled
Try adding "-lm"

Hi -

#include <math.h> is a compile-time thing. You also need to add "-lm" to link the math library into your executable.

Try something like this:
Quote:
gcc -o myprog myprog.c -lm
'Hope that helps .. PSM
 
Old 10-19-2008, 02:47 AM   #3
warun
Member
 
Registered: Aug 2007
Posts: 39

Original Poster
Rep: Reputation: 15
hey thanks, that worked
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: Standard C Math Library not found. banso_boy Linux - Newbie 10 04-24-2008 10:30 AM
math program that I can enter math functions ... Four General 5 04-19-2006 08:02 PM
error while accessing math functions in kernel modules dypgrp Programming 0 01-19-2005 09:12 AM
Can you find the error ? (160 lines) math-cases etc Dimitris Programming 5 09-02-2003 04:42 PM
math overflow error tda Programming 12 04-03-2003 10:43 AM


All times are GMT -5. The time now is 06:37 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration