



How can I use C/C++ standard library with newlib?
by scan15g on Mar 25, 2013 |
scan15g
Posts: 5 Joined: Mar 15, 2013 Last seen: May 14, 2015 |
||
Hi, all
I 'm very newbie in bare metal application, cross-compiler. As I know, for bare-metal application, I have to use the Openrisc GNU tool chain with newlib. Is it correct? If it is correct, I have a question about C standard library with newlib. I made a simple code for test. ------------------------- int main ( int argc, char **argv ){ double *A = (double*)calloc( 1, sizeof(double) ); A[0] = 1; } ------------------------- But the linker "or32-elf-ld" showed an error message. ------------------------- or32-elf-ld init.o test.o -o eprom.elf -T or32.ld -Map eprom.map -L /opt/openrisc/or32-elf/lib/ -lc /opt/openrisc/or32-elf/lib//libc.a(lib_a-sbrkr.o): In function `_sbrk_r': /opt/gnu-stable/bd-elf/or32-elf/newlib/libc/reent/../../../../../unisrc/newlib/libc/reent/sbrkr.c:60: undefined reference to `_sbrk' ------------------------- With newlib, not allowed using C standard library? What should I do to use C standard library? Actually I'd like to use many functions in C/C++ library. But I think, I am missing something that very very basic fact... Please let me know that I missed thing... I'm sorry to bother all. Thank you |
RE: How can I use C/C++ standard library with newlib?
by jeremybennett on Mar 26, 2013 |
jeremybennett
Posts: 815 Joined: May 29, 2008 Last seen: Jun 13, 2019 |
||
Hi scan15g If you want to link with C libraries, use gcc or g++ to do the linking, not ld. It will ensure all the correct libraries, CRT files and so on are applied. In your case start with: or32-elf-gcc init.o test.o -o eprom.elf If you want to pass funny linker scripts and maps to the linker, use the GCC options (-Wl etc) to pass options to the linker. HTH, Jeremy
-- |
RE: How can I use C/C++ standard library with newlib?
by scan15g on Mar 27, 2013 |
scan15g
Posts: 5 Joined: Mar 15, 2013 Last seen: May 14, 2015 |
||
Hi Jeremy,
Thanks for the reply, the problem is simply solved. Again, I'm sorry, but I just have one more question about memory setting, for example memory size. It is good, or32-elf-gcc or g++ automatically linking and making the memory map, but I have found that I could not specify the start of the stack address. So in modelsim simulation, I have to expand the memory size can cover the current memory size is the same as start of stack address. How can I specify the memory size? Please give me a hint to solve my worries. Thank you, Regards, scan15g |
RE: How can I use C/C++ standard library with newlib?
by jeremybennett on Mar 28, 2013 |
jeremybennett
Posts: 815 Joined: May 29, 2008 Last seen: Jun 13, 2019 |
||
Hi scan15g IIRC the current implementation of newlib imposes a fixed size on the memory with which it will work, since that is what most engineers want. The previous implementation determined the available memory and set the end of stack to that point. I believe to fix this you'll need to find the location in newlib libgloss where the stack size is specified and change it (it will be in libgloss/or32) before rebuilding the tool chain. I think Julius Baxter is currently the maintainer of newlib, and may be able to give more information. You could try the mailing lists, or the IRC forum (#openrisc on freenode.net). HTH, Jeremy |
RE: How can I use C/C++ standard library with newlib?
by scan15g on Mar 29, 2013 |
scan15g
Posts: 5 Joined: Mar 15, 2013 Last seen: May 14, 2015 |
||
Hi, Jeremy
Thank you for your comment, I could find the instruction to set the memory size etc. for openrisc enviorment setup at follow link. http://opencores.org/or1k/Newlib#Board_support_details Now, I can cross-compile some C/C++ source code with Openrisc Tool Chain and execute(actually simulation) the compiled and linked binary with openrisc 1200. But, I'm afraid that I use the library(function) which is not supported by current Openrisc Tool Chain. So I would like to know the libraries that current tool chain can be supported. For newlib, I could get the documentation in "http://sourceware.org/newlib/" But newlib can be supported only C library. As I know Openrisc Tool Chain can support not only C library but also C++ library. I wouild like to get the documentation like newlib web page. Is there any documentation about supported library(function) list? Thanks for your support. Best Regards, scan15g |
RE: How can I use C/C++ standard library with newlib?
by jeremybennett on Mar 31, 2013 |
jeremybennett
Posts: 815 Joined: May 29, 2008 Last seen: Jun 13, 2019 |
||
For newlib, I could get the documentation in "http://sourceware.org/newlib/" But newlib can be supported only C library. As I know Openrisc Tool Chain can support not only C library but also C++ library. I wouild like to get the documentation like newlib web page. Hi scan15g C++ is supported just fine by newlib. The standard C++ library (part of GCC) is built on top of newlib. It is a standard library, so documented elsewhere, for example, http://www.cplusplus.com/reference/. Of course you won't get any OS features that are not supported by the underlying newlib implementation. For example bare metal OpenRISC newlib only supports a single thread. But to fix that you'll need some sort of operating system. eCos, FreeRTOS and Linux are all available for OpenRISC. HTH Jeremy |
RE: How can I use C/C++ standard library with newlib?
by scan15g on Apr 1, 2013 |
scan15g
Posts: 5 Joined: Mar 15, 2013 Last seen: May 14, 2015 |
||
Hi, Jeremy
Thank you very much, More detailed thing, I'll look on the web. Thank you for letting me know a lot of things. I'll do my best to do my work. Thank you, Best Regards scan15g |



