Hallo zusammen,
gleich vornweg - ich bin newbee im Bereich ARM und arbeite mich gerade
ein mit Hilfe des Buch "C Programming for Embedded Microcontrollers".
Ich nutze das Olimex-DevBoard At91SAM7x256 mit Eclipse und
Yagarto-Toolchain.
Bisher war alles lösbar.
Nun wollte ich die "log"-Funktion nutzen. Trotz einbinden der math.h
folgt beim Kompilieren folgende Fehlermeldung
Stefan Ernst schrieb:
> ja, beim Linken spielt die Reihenfolge eine Rolle).andenkopfschlag Natuerlich! :)
Die Zeile im Makefile koennte dann so aussehen:
Ich habe etwas rausgefunden
funkioniert nicht: Temp = log(Rtemp);
funktioniert : Temp = log(2.2);
d.h. steht ein Wert in der Klammer funktioniert es und wenn der
Variablenname innerhalb der Klammer steht macht er mir das Problem beim
Kompilieren
Dein Problem wurde schon von Stefan geloest, aber nur zur Information:
Daniel schrieb:
> funktioniert : Temp = log(2.2);> funkioniert nicht: Temp = log(Rtemp);
Du verwendest einen neuen GCC? Der erkennt, dass log(2.2) eine Konstante
ist und ersetzt den Funktionsaufruf mit dem Ergebnis des Ausdrucks.
Das Ergebnis von log(Rtemp) ist zur Kompilationszeit nicht bekannt, und
GCC muss die Funktion log() also aufrufen.
Im ersten Fall wird die log()-Funktion also nicht dazugelinkt, im
zweiten Fall wird sie das. Deshalb hast du auch den Fehler nur bei der
zweiten Variante bekommen.
Thomas Pircher schrieb:
> Du verwendest einen neuen GCC? Der erkennt, dass log(2.2) eine Konstante> ist und ersetzt den Funktionsaufruf mit dem Ergebnis des Ausdrucks.
Huh, der Compiler rechnet Logarithmusfunktionen aus? Cool.
Mark Brandis schrieb:
> Huh, der Compiler rechnet Logarithmusfunktionen aus? Cool.
GCC kann das seit v4.3. Ein Auszug aus
http://gcc.gnu.org/gcc-4.3/changes.html :
> The GCC middle-end has been integrated with the MPFR library. This allows> GCC to evaluate and replace at compile-time calls to built-in math> functions having constant arguments with their mathematically equivalent> results. In making use of MPFR, GCC can generate correct results> regardless of the math library implementation or floating point precision> of the host platform. This also allows GCC to generate identical results> regardless of whether one compiles in native or cross-compile> configurations to a particular target. The following built-in functions> take advantage of this new capability: acos, acosh, asin, asinh, atan2,> atan, atanh, cbrt, cos, cosh, drem, erf, erfc, exp10, exp2, exp, expm1,> fdim, fma, fmax, fmin, gamma_r, hypot, j0, j1, jn, lgamma_r, log10, log1p,> log2, log, pow10, pow, remainder, remquo, sin, sincos, sinh, tan, tanh,> tgamma, y0, y1 and yn. The float and long double variants of these> functions (e.g. sinf and sinl) are also handled. The sqrt and cabs> functions with constant arguments were already optimized in prior GCC> releases. Now they also use MPFR.
DANKE! auch von mir. Der Witz ist nämlich, auf Linux ubuntu
2.6.38-11-generic geht mein Aufruf
$ gcc -D_REENTRANT -Wall -lm -lpcan -lpthread -o s2algo
tools/sens2algos.c
ohne Probleme. Dagegen haut's mir den auf
Linux ubuntu 3.5.0-36-generic #57~precise1-Ubuntu SMP
um die Ohren. Ich habe's nicht verstanden. Mit
$ gcc -D_REENTRANT -Wall -pthread -o s2algo tools/sens2algos.c -lm
-lpcan
wurde ich glücklich.
Und ich habe ernsthaft 1.5 Tage recherchiert!!