maths functions

I have a program that compiles fine when no math.h functions are used but
when powf, expf etc are used gives the error:

qcc pcitest.c -o pcitest

/tmp/AAA780071_cc.o: In function process_image': /tmp/AAA780071_cc.o(.text+0x170c): undefined reference to powf’
/tmp/AAA780071_cc.o(.text+0x172f): undefined reference to powf' /tmp/AAA780071_cc.o(.text+0x1770): undefined reference to expf’
cc: /usr/ntox86/bin/ld error 1

I do have the #include <math.h> line and math.h exists in usr/include. What
is wrong here?

Paul.

“Paul Jones” <paul.jones@bnc.ox.ac.uk> wrote in message
news:9vktj7$sef$1@inn.qnx.com

I have a program that compiles fine when no math.h functions are used but
when powf, expf etc are used gives the error:

qcc pcitest.c -o pcitest

/tmp/AAA780071_cc.o: In function process_image': /tmp/AAA780071_cc.o(.text+0x170c): undefined reference to powf’
/tmp/AAA780071_cc.o(.text+0x172f): undefined reference to powf' /tmp/AAA780071_cc.o(.text+0x1770): undefined reference to expf’
cc: /usr/ntox86/bin/ld error 1

I do have the #include <math.h> line and math.h exists in usr/include.
What
is wrong here?

Just including the header isn’t enough, you need to tell the linker to link
in the math library. Add a -lm to your compile command line parameters
(stick it at the end).

Eg. qcc pcitest.c -o pcitest -lm

-Adam