wujiangang / ESP8266_IOT_PLATFORM

A demo that should be run with ESP8266 RTOS SDK
http://bbs.espressif.com
Other
239 stars 122 forks source link

MacOS X: undefined reference to `floor'/`pow` #3

Closed neuhalje closed 6 years ago

neuhalje commented 8 years ago

Solution see below (last comment)

Compilation under MacOSX fails (paths shortened, output formatted):

...
xtensa-lx106-elf-gcc  -L$ESP8266_RTOS_SDK/lib -Wl,--gc-sections -nostdlib \
   -T$ESP8266_RTOS_SDK/ld/eagle.app.v6.ld \
   -Wl,--no-check-sections -u call_user_start -Wl,\
   -static -Wl,--start-group -lminic -lgcc -lhal -lphy -lpp -lnet80211 \
   -lcrypto -lwpa -lmain -lfreertos -llwip -lssl -ljson -lsmartconfig \
   -lpwm -L./libesphttpd -lesphttpd -lwebpages-espfs \
   user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a \
   upgrade/.output/eagle/debug/lib/libupgrade.a -Wl,--end-group \
   -o .output/eagle/debug/image/eagle.app.v6.out
$ESP8266_RTOS_SDK/lib/libjson.a(cJSON.o):(.text.print_number+0x48): undefined reference to `floor'
$ESP8266_RTOS_SDK/lib/libjson.a(cJSON.o):(.text.print_number+0x148): undefined reference to `floor'
$ESP8266_RTOS_SDK/lib/libjson.a(cJSON.o):(.text.parse_value+0x14): undefined reference to `pow'
$ESP8266_RTOS_SDK/lib/libjson.a(cJSON.o):(.text.parse_value+0x270): undefined reference to `pow'

Including -lm fails with .../newlib-2.0.0/.../w_pow.c:198: more undefined references to __errno follow

diff --git a/Makefile b/Makefile
index 1e70fd0..4032482 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,7 @@ LINKFLAGS_eagle.app.v6 = \
        -llwip  \
        -lssl   \
        -ljson  \
+       -lm  \
        -lsmartconfig \
        -lpwm \
        -L./libesphttpd \
neuhalje commented 8 years ago

Also linking to libc (which contains __errno) results in a too big image, even for a 4096KB(1024KB+1024KB) configuration: .output/eagle/debug/image/eagle.app.v6.out section '.text' will not fit in region 'iram1_0_seg'

diff --git a/Makefile b/Makefile
index 1e70fd0..558f382 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,8 @@ LINKFLAGS_eagle.app.v6 = \
        -llwip  \
        -lssl   \
        -ljson  \
+       -lm  \
+       -lc  \
        -lsmartconfig \
        -lpwm \
        -L./libesphttpd \
neuhalje commented 8 years ago

Solution

This makes it compile, even with 512KB( 256KB+ 256KB):

diff --git a/Makefile b/Makefile
index 1e70fd0..ef2e43e 100644
--- a/Makefile
+++ b/Makefile
@@ -87,11 +87,9 @@ LINKFLAGS_eagle.app.v6 = \
        -lesphttpd \
        -lwebpages-espfs \
        $(DEP_LIBS_eagle.app.v6)                                        \
-       -Wl,--end-group
-
-
-#      -lcirom \
+       -Wl,--end-group \
        -lmirom \
+       -lcirom \

 DEPENDS_eagle.app.v6 = \
                 $(LD_FILE) \
neuhalje commented 6 years ago

worked for me