avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] math linking problem even with -lm


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] math linking problem even with -lm
Date: Tue, 21 Jun 2005 22:43:24 +0200 (MET DST)

(Btw., please subscribe so you'll see people's responses.)

Andrew McNabb <address@hidden> wrote:

> avr-gcc -mmcu=3Datmega8 -lm -L/usr/avr/lib  sound1.o   -o sound1
> sound1.o: In function `__vector_8':
> sound1.c:(.text+0xac): undefined reference to `sin'
> make: *** [sound1] Error 1

Order is important when linking.  By the time the linker processes
your -lm option, it doesn't have anything that needs to be resolved by
a module found in libm.a, so it proceeds with the next command-line
argument.  That one will eventually trigger the reference to a symbol
named "sin", but no further library on the command-line could resolve
that symbol.

So just change that to

avr-gcc -mmcu=atmega8 -o sound1 sound1.o -lm

Btw., I'd personally avoid using time-consuming functions like
trigonometrical functions within an interrupt vector.  Heck, I'd avoid
calling *any* function from within an interrupt vector, as it will
make the compiler push/pop a lot more registers than needed without
that.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]