ESP8266 Developer Zone The Official ESP8266 Forum 2018-04-06T22:02:51+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=9432 2018-04-06T22:02:51+08:00 2018-04-06T22:02:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=9432&p=19950#p19950 <![CDATA[Re: Linking against the math library]]>

Code:

[b]-Wl,[/b]--start-group -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lhal -lc -lgcc -ldriver [b]-lm[/b] [b]-Wl,--end-group[/b]


Moreover, the fmod() and fmof() are relying by default on the the libgcc function _ieee754_remainder() which is not implemented by the XTensa compiler what break the compilation. To fix it, you can edit crosstool-NG/.build/src/newlib-2.0.0/newlib/libm/math/ef_fmod.c and change the #ifdef from 1 to 0 to enable the native version of fmod() that is independant from _ieee754_remainder() and recompile the SDK.

With this two fixes, I got a fully functionnal math library.

Statistics: Posted by Pato — Fri Apr 06, 2018 10:02 pm


]]>
2018-03-24T01:18:47+08:00 2018-03-24T01:18:47+08:00 https://bbs.espressif.com:443/viewtopic.php?t=9432&p=19741#p19741 <![CDATA[Linking against the math library]]>
I'm trying to build the blinky example where I added a simple cos() and included math.h, with a toolchain based on the esp-open-sdk toolchain, and using the ESP8266_NONOS_SDK-2.2.0.

However it fails at linking stage because of the cos() with errors like these:
.../xtensa-lx106-elf/lib/libm.a(lib_a-k_rem_pio2.o):(.literal+0x1c): undefined reference to '__gedf2'

I tried several linker flags as -lm, -lmirom, etc at various position, and even the libmirom.a from the RTOS SDK as suggested here (https://bbs.espressif.com/viewtopic.php ... math#p3254) but with same error. And according to this same post the math library IS implemented.

So, how do you link or use the math library ? :)
Thx!

Statistics: Posted by Pato — Sat Mar 24, 2018 1:18 am


]]>