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.
undefined reference to `strtod' undefined reference to `strtol'
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: undefined reference to `strtod' undefined reference to `strtol'
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?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: undefined reference to `strtod' undefined reference to `strtol'
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
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: undefined reference to `strtod' undefined reference to `strtol'
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...
Disclaimer - I'm not a C guru. Hopefully one will pop up...
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: undefined reference to `strtod' undefined reference to `strtol'
What’s your linker command?
Sent from my iPhone using Tapatalk Pro
Sent from my iPhone using Tapatalk Pro
Re: undefined reference to `strtod' undefined reference to `strtol'
You might have to include it in the linker command.pythoncoder wrote: ↑Thu Sep 06, 2018 7:10 amThese 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'
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
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'
Thank you for your reply, I think I will still compile it with my own files.