This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
static link errors with libm
- From: Jaap Eldering <eldering at phys dot uu dot nl>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 14 Aug 2004 19:25:23 +0200
- Subject: static link errors with libm
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