Forum: Compiler & IDEs AVR32UC3C-EK math.h wird nicht richtig genutzt


von Moritz A. (momo87)


Lesenswert?

Guten Tag,

ich habe ein Problem in AVR-Studio 5 mit meinem UC3C-EK Board.
Es ist mit einem AVR32UC3C0512C bestückt.
Wenn ich Funktionen der math.h verwende (Bsp.: cos(x)) sind diese
bereits definiert :

•
1
#define cos(x) fast_cos(x)
Die Definition geschieht in der fast_math.h . Diese wurde allerdings
zu keinem Zeitpunkt eingebunden, und auch wenn ich sie einbinde 
funktioniert der Cosinus nicht. Ich würde allerdings gerne die 
Funktionen der einfachen math.h verwenden.

In der math.h selbst werden auch von Beginn an die Funktionsnamen 
umdefiniert und einige haben garkeine Definition mehr (Bsp.: pow()).
In einigen Beispielen zu diesem Board wird die math.h allerdings 
verwendet und dort tritt dies nicht auf.

Version AVR-Studio : 5.0.1223
Version Toolbchain : 4.5.3
Version Framework  : 2.8.1

Kennt vll. jemand dieses Problem oder wüsste eine Lösung dazu ?

Mit freundlichen Grüßen,
Moritz Auler

von Jens A. (micro)


Lesenswert?

Hallo,

Ich nutze auch uc3c. Was genau funktioniert den nicht?

Liegt es eventuell an der Option das die CPU unterstüzt ist.
Hast du im config.mk die richtige Architekturen angegeben

Ucr3fp

von Oliver (Gast)


Lesenswert?

Moritz Auler schrieb:
> Kennt vll. jemand dieses Problem

Was genau ist denn jetzt das Problem?

Oliver

von Moritz A. (momo87)


Lesenswert?

Hi ,

also , das Problem ist :

Ich kann keine Funktionen der math.h nutzen.
Es kommt immer folgender Fehler :

Error  1  undefined reference to `cos'

Dabei hab ich die math.h eingebunden.
Wenn ich auf cos(x) gehe zeigt er folgendes an :

•
1
#define cos(x) fast_cos(x)
Wie oben genannt wird dies -in der von mir nicht eingebundenen-
fast_math.h gemacht. Wenn ich die fast_math.h einbinde zeigt
er mir allerdings den gleichen Fehler, somit kann ich garkeine
Befehle wie cos , sin etc. verwenden, die ich allerdings brauche..

Eingebunden hab ich :
•
1
#include <asf.h>
2
#include "gpio.h"
3
#include <math.h>
@Jens : Hat leider keine Veränderung gebracht.

Moritz

von Oliver (Gast)


Lesenswert?

Moritz Auler schrieb:
> Error  1  undefined reference to `cos'

Das ist wohl kaum die vollständige Fehlermeldung.

WEnn die Meldung vom linker kommt, hast du vermutlich vergessen, die 
mathelib dazuzulinken. Üblicherweise hilft da ein Blick in die 
Projektoptionen.

Oliver

von Moritz Auler (Gast)


Lesenswert?

Hm,

im Toolchain kann ich dem Linker Libraries hinzufügen, allerdings finde 
ich keine mathlib.

Hier mal ein Ausschnitt der aufschlussreich sein könnte :

•
1
In file included from ../src/main.c:16:
2
C:\Users\aum\Documents\AVRStudio\FFT_Test_4\FFT_Test_4\src\math.h(344,1): function declaration isn't a prototype
3
C:\Users\aum\Documents\AVRStudio\FFT_Test_4\FFT_Test_4\src\math.h(357,1): function declaration isn't a prototype
4
    Finished building: ../src/main.c
5
    Building target: FFT_Test_4.elf
6
    Invoking: AVR32/GNU C/C++ Linker
7
    "C:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr32-gcc.exe" -nostartfiles -L"../../../../../../Program Files/Atmel/AVR Studio 5.0/AVR Toolchain/lib/gcc/avr32/4.4.3/ucr3fp"  -Wl,--gc-sections -
8
9
T../src/asf/avr32/utils/linker_scripts/at32uc3c/0512c/gcc/link_uc3c0512c.lds -Wl,--relax -Wl,-e,_trampoline  -mpart=uc3c0512c  -o FFT_Test_4.elf  src/asf/avr32/boards/uc3c_ek/init.o src/asf/avr32/drivers/flashc/flashc.o src/asf/avr32/drivers/gpio/gpio.o 
10
11
src/asf/avr32/drivers/intc/exception.o src/asf/avr32/drivers/intc/intc.o src/asf/avr32/drivers/pm/pm_uc3c.o src/asf/avr32/drivers/pm/power_clocks_lib.o src/asf/avr32/drivers/scif/scif_uc3c.o src/asf/avr32/drivers/usart/usart.o 
12
13
src/asf/avr32/utils/debug/print_funcs.o src/asf/avr32/utils/startup/startup_uc3.o src/asf/avr32/utils/startup/trampoline_uc3.o src/asf/common/services/clock/uc3c/osc.o src/asf/common/services/clock/uc3c/pll.o 
14
15
src/asf/common/services/clock/uc3c/sysclk.o src/FFT.o src/fpu_math.o src/main.o  
16
src/asf/avr32/boards/uc3c_ek/init.o(0,0): input is not relaxable
17
src/asf/avr32/drivers/flashc/flashc.o(0,0): input is not relaxable
18
src/asf/avr32/drivers/gpio/gpio.o(0,0): input is not relaxable
19
src/asf/avr32/drivers/intc/intc.o(0,0): input is not relaxable
20
src/asf/avr32/drivers/pm/pm_uc3c.o(0,0): input is not relaxable
21
src/asf/avr32/drivers/pm/power_clocks_lib.o(0,0): input is not relaxable
22
src/asf/avr32/drivers/scif/scif_uc3c.o(0,0): input is not relaxable
23
src/asf/avr32/drivers/usart/usart.o(0,0): input is not relaxable
24
src/asf/avr32/utils/debug/print_funcs.o(0,0): input is not relaxable
25
src/asf/common/services/clock/uc3c/osc.o(0,0): input is not relaxable
26
src/asf/common/services/clock/uc3c/pll.o(0,0): input is not relaxable
27
src/asf/common/services/clock/uc3c/sysclk.o(0,0): input is not relaxable
28
src/FFT.o(0,0): input is not relaxable
29
src/fpu_math.o(0,0): input is not relaxable
30
src/main.o(0,0): input is not relaxable
31
    src/FFT.o: In function `fftinit':
32
C:\Users\aum\Documents\AVRStudio\FFT_Test_4\FFT_Test_4\Debug/../src/FFT.c(27,1): undefined reference to `cos'
33
    src/main.o: In function `main':
34
C:\Users\aum\Documents\AVRStudio\FFT_Test_4\FFT_Test_4\Debug/../src/main.c(74,1): undefined reference to `cos'
35
    src/main.o: In function `init_hann':
36
C:\Users\aum\Documents\AVRStudio\FFT_Test_4\FFT_Test_4\Debug/../src/main.c(84,1): undefined reference to `cos'
37
    collect2: ld returned 1 exit status
38
    make: *** [FFT_Test_4.elf] Error 1
39
  Done executing task "RunAvrGcc32" -- FAILED.
40
Done building target "CoreBuild" in project "FFT_Test_4.avrgccproj" -- FAILED.
41
Done building project "FFT_Test_4.avrgccproj" -- FAILED.
42
43
Build FAILED.
44
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

von Oliver (Gast)


Lesenswert?

Die mathelib nennt sich seit Anbegin der Zeiten libm. Die brauchst du 
nicht zu suchen, die gibt es.

Oliver

von Jens A. (micro)


Lesenswert?

Hallo,

verwendest du ein config.mk file
oder das integrierte Build tool von avr studio.

Wenn du avr Studio nutzt dann must du in den einstellungen ein
Häckchen bei der Math lib machen.

Wenn du config.mk nutzt dann
LIB = m

von JeroendB (Gast)


Lesenswert?

Hello,

I can read German, but not write it (I'm Belgian), so I will write 
English.
Are you sure that you have imported the "GCC math library for 32-bit AVR 
(service)" in the Atmel Software Framework Wizard and have put the knob 
on yes in it?

Grtz,

Jeroen

von Dittmar L. (dittmarlange)


Lesenswert?

Hi Jeroen,

I had the same problem like Moritz and I included the "GCC math library 
for 32-bit AVR (service)" in the ASF Wizard and puted the knob on yes, 
but I could not find any header file or somthing else where I could see 
the names of the function that are included in this lib!? Is there some 
kind of documentation for this lib?!

Many thanks
Dittmar


Jeroen schrieb:
> Hello,
>
> I can read German, but not write it (I'm Belgian), so I will write
> English.
> Are you sure that you have imported the "GCC math library for 32-bit AVR
> (service)" in the Atmel Software Framework Wizard and have put the knob
> on yes in it?
>
> Grtz,
>
> Jeroen

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.
Lade...