C Error Undefined Reference To Pow
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring undefined reference to pow collect2 ld returned 1 exit status developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask undefined reference to pow in gcc Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join
Undefined Reference To Pow Ubuntu
them; it only takes a minute: Sign up Undefined reference to `pow' and `floor' up vote 72 down vote favorite 19 I'm trying to make a simple fibonacci calculator in C but when compiling gcc tells me that I'm
Undefined Reference To Pow' Makefile
missing the pow and floor functions. What's wrong? Code: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about
Undefined Reference To `pow' Cmake
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask undefined reference to `__pthread_register_cancel' Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. how to use pow function in gcc Join them; it only takes a minute: Sign up Undefined Reference error for power function in C [duplicate] up vote 1 down vote favorite Possible Duplicate: Problem using pow() in C Undefined reference to pow' andfloor' I am using http://stackoverflow.com/questions/8671366/undefined-reference-to-pow-and-floor gcc 4.6.1. Code snippet: int main(void) { int x= 2; int y = pow(3,x); printf("%d\n",y); return 0; } Terminal: avinash@titanic:~/Desktop/DSF$ gcc power.c -o power /tmp/ccTJ7vAH.o: In function `main': power.c:(.text+0x25): undefined reference to `pow' collect2: ld returned 1 exit status If I replace x by 2 then it gets executed in an expected way. Doesn't pow function accepts variables as it's parameters? Note: I have included stdio.h and math.h in the source file. c gcc pow share|improve this question http://stackoverflow.com/questions/9025015/undefined-reference-error-for-power-function-in-c edited Sep 15 at 13:23 metadings 2,71411429 asked Jan 26 '12 at 20:40 Avinash Sonawane 41125 marked as duplicate by Tim Cooper, ruakh, Bo Persson, Mac, pmg Jan 26 '12 at 20:51 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. If you have pow(3,2) the compiler can compute that directly and doesn't have to call the function. –Bo Persson Jan 26 '12 at 20:45 If you included stdio.h and math.h in the source file, then show us that in the code rather than showing us incomplete code and then telling us what's missing. –Keith Thompson Jan 26 '12 at 20:54 @KeithThompson- Sorry. But "include" term was appearing to be Bold without actually going for the bold type. So I dropped the #include lines, but i have mentioned that I have included both the libraries under note. –Avinash Sonawane Jan 26 '12 at 21:00 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote You need to add the -lm command-line switch to link in the math library (-l... means "link in the __ library"; m is the math library): gcc power.c -lm -o power share|improve this answer edited Jan 26 '12 at 20:51 answered Jan 26 '12 at 20:42 ruakh 93.9k9133184 2 Or rather gcc
Programming Boards C Programming "Undefined Reference" to pow and sqrt even though math.h header is there Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ http://cboard.cprogramming.com/c-programming/79669-undefined-reference-pow-sqrt-even-though-math-h-header-there.html | Get a compiler | Fixes for common problems Thread: "Undefined Reference" to pow and http://www.linuxquestions.org/questions/linux-general-1/error-undefined-reference-while-compiling-a-c-program-in-linux-893227/ sqrt even though math.h header is there Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 06-01-2006 #1 yougene View Profile View Forum Posts Registered User Join Date May 2006 Posts 182 "Undefined Reference" to pow and sqrt even though math.h header is there Compiling undefined reference this code tells me that there is no reference to pow() or sqrt(). The book didn't tell me under which header these functions are located but I assume they are under math.h. Am I missing something here? Code: #include
HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > Linux - General Error "Undefined reference" while compiling a c program in linux User Name Remember Me? Password Linux - General This Linux forum is for general Linux questions and discussion. If it is Linux Related and doesn't seem to fit in any other forum then this is the place. Notices Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread 0