Give the compiler also the option: -lm. Because: the math.h just gives the function prototypes...but what the compiler really needs, the symbols of the library, are in libm.a, which you need to link with the above option. Ronny Iversen wrote: > #include <stdio.h> > #include <math.h> > /*test.c*/ > > void main(void) { > sprintf("%ld\n", pow(2,2)); > } > > When I compile this with gcc test.c I get the following errors, anybody knows > whats wrong? > Im using redhat 5.1 > /tmp/cca136931.o: In function `main': > /tmp/cca136931.o(.text+0x12): undefined reference to `pow' > - Chris -- /----------------------------------------------------------------------------\ | Christian Loth, chris@rom.mud.de | REALM OF MAGIC | | http://rom.mud.de/~chris | telnet rom.mud.de 4000 | | | http://rom.mud.de/ | \----------------------------------------------------------------------------/ +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST