math - pow - unknown
by Jens Allmer - Hi,
I am experiencing a strange issue with a C program question.
Even though I include <math.h> in the Answer, I get the following error message:
/tmp/ccLd97P7.o: In function `binToDez': __tester__.c:(.text+0x1cc): undefined reference to `pow' collect2: error: ld returned 1 exit statusThe question is attached in moodle format.
Any ideas?
Thank you,
Jens
Re: math - pow - unknown
by Richard Lobb - This error message comes from the linker. The gnu linker doesn't search the math library by default - you need to customise the question, or edit its prototype, and add the "-lm" link argument. See https://coderunner.org.nz/mod/forum/discuss.php?d=172
I agree it seems a bit pathetic that you should have to do that, but it is the standard default Linux C behaviour. However, I'll update the built-in C and C++ question types to include the -lm link option in the next release. You'll still need to specify appropriate link options for other libraries, however.