This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]