Error Undefined Reference To Pow In C
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 undefined reference to pow collect2 ld returned 1 exit status Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Undefined Reference To Pow In Gcc
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community math.h undefined reference to pow of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined reference to pow( ) in C, despite including math.h [duplicate] up vote 17 down vote favorite undefined reference to pow ubuntu 6 Possible Duplicate: Problem using pow() in C what is 'undefined reference to `pow'' I'm having a bit of an issue with a simple piece of coursework for uni that's really puzzling me. Essentially, I've to write a program that, amongst other things, calculates the volume of a sphere from a given radius. I thought I'd use the pow() function rather than simply using r*r*r, for extra Brownie points, but the
Undefined Reference To Pow' Makefile
compiler keeps giving me the following error: undefined reference to 'pow' collect2: error: ld returned 1 exit status My code looks like the following: #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 undefined reference to `pow' cmake site About Us Learn more about Stack Overflow the company Business Learn more undefined reference to pow' eclipse about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x
Undefined Reference To `__pthread_register_cancel'
Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up what is http://stackoverflow.com/questions/12824134/undefined-reference-to-pow-in-c-despite-including-math-h 'undefined reference to `pow'' [duplicate] up vote 5 down vote favorite 1 This question already has an answer here: Undefined reference to `pow' and `floor' 5 answers I have a codepad . On line 15 inside a for function for(i=2; i<=90; i+=2){ int j=0+i; printf("%i\n",i); power=pow(inp,j); factor=factorial(i); if(i%4==0)fAns += power/factor; else fAns -= power/factor; } the line power=pow(inp,j); I added j instead of just http://stackoverflow.com/questions/10167714/what-is-undefined-reference-to-pow using i because it gave me the same error. undefined reference to 'pow'. If I replace j with 2, then it works just fine but when I use j=i it wont work. Is there a problem with incrementing this line? I want this to increment and not throw me an error. c share|improve this question edited Apr 16 '12 at 1:23 Mysticial 282k35240264 asked Apr 16 '12 at 1:23 user1082764 55331328 marked as duplicate by alkc Users with the c badge can single-handedly close c questions as duplicates and reopen them as needed. Jun 8 '14 at 14:52 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. 1 Gcc is cheating :) See this –Deqing Aug 26 '14 at 9:02 add a comment| 1 Answer 1 active oldest votes up vote 17 down vote You need to link with the math library. With gcc, this would mean passing -lm during linking. The reason it doesn't complain when you use 2 as the exponent value is because the compiler is optimizing the pow
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 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