Re: Linking c programs?
On Sun, Jul 04, 1999 at 05:10:59PM +0100, Andrew Holmes wrote:
> Hi,
>
> I've been trying to compile a c program which uses maths functions like pow()
> and cbrt(), I've included the #include <math.h> and it compiles to an object
> ok. However when I try to compile it to a program I get:
>
> /tmp/ccc13322: In function `difi':
> /tmp/ccc13322(.text+0xea): undefined reference to `cbrt'
>
> Am I supposed to use some command line to gcc to make it work, I've been using
>
> gcc -o it it.c
>
> to make a program called 'it' from the source 'it.c'
>
> Any help would be greatly appreciated, TIA
>
you also must link against the associated libraries of your includes,
in your case libm, with the compiler switch -l.
you need not to give the full name "libm" "m" is enough. so your command
line should look like:
gcc -lm -o it it.c
HTH
robert
--
in a world without fences, who needs gates?
-- das $yndikat lebt -- Abteilung Linux --
Reply to: