[Solved] Problems linking with math library - undefined "__fpclassifyd"

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Solved] Problems linking with math library - undefined "__fpclassifyd"

Postby kolban » Thu Sep 29, 2016 5:16 am

I have some code that is including "math.h" from components/newlib/include/math.h

In that header there is an external reference to:

Code: Select all

extern int __fpclassifyd (double x);
when I link my application, I am getting an error stating:

Code: Select all

jswrap_functions.c:(.text.jswrap_parseInt+0x27): undefined reference to `__fpclassifyd'
It is important to note that the link step I am using is the following:

Code: Select all

xtensa-esp32-elf-gcc -Winline -Og -Wl,--gc-sections -nostdlib -u call_user_start_cpu0 \
-Wl,--gc-sections -Wl,-static -Wl,-EL \
-Wl,--start-group \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.common.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.rom.ld \
-T/home/pi/projects/esp32/esp-idf/components/esp32/ld/esp32.peripherals.ld \
/home/pi/projects/esp32/esp-idf/components/newlib/lib/libc.a \
/home/pi/projects/esp32/esp-idf/components/newlib/lib/libm.a \
-Wl,--end-group -o espruino_1v87.213_esp32.elf src/jslex.o .... // many more .o files
I also found a mysterious file called "components/newlib/lib/extracted/romsys" which appears to list the entry "__fpclassifyd".

Can anyone spot where I must possibly be going wrong?
Last edited by kolban on Fri Sep 30, 2016 3:11 pm, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Problems linking with math library - undefined "__fpclassifyd"

Postby WiFive » Thu Sep 29, 2016 6:29 am

It is listed in romsys but not in esp32.rom.ld so can't be linked

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: Problems linking with math library - undefined "__fpclassifyd"

Postby ESP_Sprite » Thu Sep 29, 2016 7:27 am

Can you file an issue on Github for this? Sounds like the script that generates the rom ld file may have skipped over this because of the double underscore.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Problems linking with math library - undefined "__fpclassifyd"

Postby kolban » Thu Sep 29, 2016 1:47 pm

Thank you guys. Git hub issue #33 raised.

Later ...

The problem was resolved and it was discovered to be a mistake on my part in my linking step. I had failed to include my source compiled object files in the --start-group / --end-group recursive linking definition. Once I moved my code to be within the recursive resolution group, the linker completed without error.

To be explicit ... I was linking incorrectly with:

Code: Select all

-Wl,--start-group <ESP-IDF libs> -Wl,--end-group <my object files>
when what I should have been doing was:

Code: Select all

-Wl,--start-group <ESP-IDF libs> <my object files> -Wl,--end-group 
If you are using the ESP-IDF makefiles, you shouldn't ever have to worry about this knowledge. I include for completeness in case a similar error is encountered down the line and these words may provide hints to the next person.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Problems linking with math library - undefined "__fpclassifyd"

Postby WiFive » Fri Sep 30, 2016 2:17 am

So how does this reconcile the mismatch between romsys and esp32.rom.ld?

Who is online

Users browsing this forum: ccrause and 242 guests