Page 1 of 1

undefined reference to `strtod' undefined reference to `strtol'

Posted: Wed Sep 05, 2018 2:39 am
by Jack-123
Hello, I want to compile my own package into Micropython, but I am getting an error when compiling. The error message is:
undefined reference to strtod' undefined reference tostrtol'
How can I do? thank you.

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Wed Sep 05, 2018 7:31 am
by pythoncoder
You'll need to provide a lot more information if anyone is to help you, notably your build command and the resultant traceback. Also what OS and compiler version are you using?

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Wed Sep 05, 2018 8:34 am
by Jack-123
Thank you very much for your reply. I have a temporary solution: I wrote the `strtol' and `strtod' files myself, but I don't know what the pitfalls are.
Here is my basic situation:
1. Ubuntu arm-none-eabi-gcc-4.9.3
2, makefile In addition to adding my package file, the other did not make changes
3. Where the error occurred:
Unsigned char temp = 0;
temp = (unsigned char)(strtod(&g_cmd_b_p->cmd_buffer[g_cmd_b_p->cmd_queue_cnt][c_postion + 1], NULL)) ;
temp = (strtol(&g_cmd_b_p->cmd_buffer[g_cmd_b_p->cmd_queue_cnt][c_postion + 1],NULL,10));
4, the error message:
build-PYBV11/code/get_command.o: In function `checksum_dealwith_command':
get_command.c:(.text.checksum_dealwith_command+0x3e): undefined reference to `strtod'
build-PYBV11/code/get_command.o: In function `line_checksum_dealwith_command':
get_command.c:(.text.line_checksum_dealwith_command+0x34): undefined reference to `strtol'
Makefile:537: recipe for target 'build-PYBV11/firmware.elf' failed

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Thu Sep 06, 2018 7:10 am
by pythoncoder
These functions are part of the C standard library so I wonder if something is wrong with your gcc installation?

Disclaimer - I'm not a C guru. Hopefully one will pop up...

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Thu Sep 06, 2018 1:51 pm
by jickster
What’s your linker command?


Sent from my iPhone using Tapatalk Pro

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Thu Sep 06, 2018 4:09 pm
by jickster
pythoncoder wrote:
Thu Sep 06, 2018 7:10 am
These functions are part of the C standard library so I wonder if something is wrong with your gcc installation?

Disclaimer - I'm not a C guru. Hopefully one will pop up...
You might have to include it in the linker command.

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Thu Sep 06, 2018 4:17 pm
by dhylands
Micropython doesn't link against the C runtime library. It provides its own version of the very small number of functions that it needs.
https://github.com/micropython/micropyt ... r/lib/libc

Normally the python parser would convert strings into numbers. I found an example in ujson where it converts string version of numbers into numbers:
https://github.com/micropython/micropyt ... #L180-L201

Re: undefined reference to `strtod' undefined reference to `strtol'

Posted: Mon Sep 10, 2018 7:07 am
by Jack-123
Thank you for your reply, I think I will still compile it with my own files.