Re: static link errors with libm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try -lm as the last command-line argument to gcc
-ishwar


On Sat, 14 Aug 2004, Jaap Eldering wrote:

> Hello,
>
> I'm having problems linking statically with the math library.
>
> When compiling the following program:
>
> #include <math.h>
>
> int main()
> {
>         sin(0);
>         return 0;
> }
>
> with 'gcc -static -lm -o progname progname.c', I get errors:
>
> /tmp/ccZSyXXG.o: In function `main':
> /tmp/ccZSyXXG.o(.text+0xe): undefined reference to `sin'
> collect2: ld returned 1 exit status
>
> while without the -static option, all is fine. More strangly, if I
> compile with 'g++ -x c -static -lm -o progname progname.c' then it
> compiles fine too.
>
> I have this problem on Debian stable with gcc 2.95.4 and 3.0.4 and on
> SunOS with gcc 3.2.2, but not on Compaq Tru64 UNIX V5.1A with gcc 3.4.1
>
> Thanks for any help,
> Jaap Eldering
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux