I needed some new features of the C++ library and so I tried to get NewLib to work. After much effort, I was able to get it to work but I ran into some issues I don't understand.
I turned off the ES standard library by selecting No for Project Options->Libraries->Include Standard Libraries. I also set Project Options->Libraries->Standard Libraries Directory to None.
I put the NewLib library files on my machine at: C:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
So, I set Project Options->Linker->Additional Linker Options to:
--verbose -LC:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
-lc
Here is relevant portion of the output from the linker:
1> Linking Blinky.elf
1> "C:/Program Files/SEGGER/EmbeddedStudio/gcc/arm-none-eabi/bin/ld" -X --omagic -eReset_Handler --fatal-warnings --verbose -LC:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard -lc -EL --gc-sections -TC:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ld -Map Debug/Blinky.map --defsym=end=__heap_start__ -u_vectors -o Debug/Blinky.elf --emit-relocs --start-group @C:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ind --end-group
1> GNU ld (GNU Binutils) 2.30.0.20180329
1> Supported emulations:
1> armelf
1> opened script file C:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ld
Then a little later:
1> ==================================================
1> attempt to open C:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc.a succeeded
This a little later:
1> Debug/usbh_cdc.o: In function `USBH_CDC_InterfaceInit':
1> C:\Depot\Source\32F401Disc\Blinky\Middlewares\ST\STM32_USB_Host_Library\Class\CDC\Src/usbh_cdc.c:170: undefined reference to `malloc'
1> Debug/usbh_cdc.o: In function `USBH_CDC_InterfaceDeInit':
1> C:\Depot\Source\32F401Disc\Blinky\Middlewares\ST\STM32_USB_Host_Library\Class\CDC\Src/usbh_cdc.c:296: undefined reference to `free'
Build failed
If I add libc.a to the project by adding the line below to the emProject file, I have no link issues.
<file file_name="../../Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libc.a"> />
Help, please. I cannot work out why the linker won't pick up libc.a when using Project Options->Linker->Additional Linker Options
Thanks,
Harjit
PS: I'm happy to post a detailed note on how to get NewLib to work with ES. I wish/beg you to update the library. I think you guys do a fine job overall but this area is seriously lagging.
I turned off the ES standard library by selecting No for Project Options->Libraries->Include Standard Libraries. I also set Project Options->Libraries->Standard Libraries Directory to None.
I put the NewLib library files on my machine at: C:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
So, I set Project Options->Linker->Additional Linker Options to:
--verbose -LC:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard
-lc
Here is relevant portion of the output from the linker:
1> Linking Blinky.elf
1> "C:/Program Files/SEGGER/EmbeddedStudio/gcc/arm-none-eabi/bin/ld" -X --omagic -eReset_Handler --fatal-warnings --verbose -LC:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard -lc -EL --gc-sections -TC:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ld -Map Debug/Blinky.map --defsym=end=__heap_start__ -u_vectors -o Debug/Blinky.elf --emit-relocs --start-group @C:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ind --end-group
1> GNU ld (GNU Binutils) 2.30.0.20180329
1> Supported emulations:
1> armelf
1> opened script file C:/Depot/Source/32F401Disc/Blinky/Debug/Blinky.ld
Then a little later:
1> ==================================================
1> attempt to open C:/Depot/Source/Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc.a succeeded
This a little later:
1> Debug/usbh_cdc.o: In function `USBH_CDC_InterfaceInit':
1> C:\Depot\Source\32F401Disc\Blinky\Middlewares\ST\STM32_USB_Host_Library\Class\CDC\Src/usbh_cdc.c:170: undefined reference to `malloc'
1> Debug/usbh_cdc.o: In function `USBH_CDC_InterfaceDeInit':
1> C:\Depot\Source\32F401Disc\Blinky\Middlewares\ST\STM32_USB_Host_Library\Class\CDC\Src/usbh_cdc.c:296: undefined reference to `free'
Build failed
If I add libc.a to the project by adding the line below to the emProject file, I have no link issues.
<file file_name="../../Library/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libc.a"> />
Help, please. I cannot work out why the linker won't pick up libc.a when using Project Options->Linker->Additional Linker Options
Thanks,
Harjit
PS: I'm happy to post a detailed note on how to get NewLib to work with ES. I wish/beg you to update the library. I think you guys do a fine job overall but this area is seriously lagging.