math - pow - unknown

math - pow - unknown

de Jens Allmer -
Número de respuestas: 1

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 status
The question is attached in moodle format.

Any ideas?

Thank you,

Jens

En respuesta a Jens Allmer

Re: math - pow - unknown

de 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.