Comments (9)
I have not tried to link the C++ or C standard library with Circle applications. What I have used is pure bare metal Circle stuff. Sometimes the order of the libraries specified on the command line of the linker does matter. But I'm not a tool expert.
from circle.
When using functions from math.h, then you need to add the linker option -lm
from circle.
Thanks for the quick response guys.
Floating point local variables or static global variables are working fine. Only the variables which are not declared as static in global scope causes those error.
@vanvught I tired adding the -lm linker option but it gives another set of error. Error log is,
/usr/arm-none-eabi/lib/libm.a(lib_a-s_floor.o): In function floor': s_floor.c:(.text.floor+0x54): undefined reference to
__aeabi_dadd'
s_floor.c:(.text.floor+0x60): undefined reference to __aeabi_dcmpgt' s_floor.c:(.text.floor+0xb0): undefined reference to
__aeabi_dadd'
s_floor.c:(.text.floor+0xe0): undefined reference to __aeabi_dadd' s_floor.c:(.text.floor+0xec): undefined reference to
__aeabi_dcmpgt'
s_floor.c:(.text.floor+0x11c): undefined reference to __aeabi_dadd' s_floor.c:(.text.floor+0x128): undefined reference to
__aeabi_dcmpgt'
Then to remove this error I tired different linker and compiler options but the error persist.
from circle.
As I wrote, I haven't tried to link the C++ or C standard library to Circle applications. But the result you have got now, is the one I would have expected: It does not work. The standard libraries are very complex software and they build on several runtime functions and start-up code which is not provided by Circle.
If you only need some math functions, you could implement them on your own, like I did here for my virtual analog synthesizer application. But this implementation has side effects on precision and handling of infinite and undefined values. In your own application you may know, how to handle these effects.
A general purpose math library is a very different thing. I had a look into the GNU C Library and this is huge stuff. Porting this to Circle would be a difficult task and should be done by someone who can handle this.
from circle.
@rsta2 Thanks for pointing me in the right direction. I'll try implementing the basic math functions that I require for my application.
One last thing I wanted to ask was about newlib. I found out that newlib is C standard library implementation intended for using on embedded systems. So will this be useful with circle?
from circle.
newlib could be interesting and I heard from one guy that he wants to port it for running with Circle. So maybe there will be something in the future.
from circle.
I have ported the newlib for baremetal Raspberry Pi -> http://www.raspberrypi-dmx.org/raspberry-pi-dmx512-rdm/development-environment
This is one part of the exercise. The next step is to implement the calls in syscall.c
For example : caddr_t _sbrk(int incr)
However, Circle has already its own malloc() and free() functions.
When you want to use console functions from the newlib, then you need to implement int _write(int file, char * ptr, int len)
All other functions in syscall.c can just returning 0, 1 or -1.
Please note that newlib is dependent on the __aeabi functions. So you still need to link with -lgcc
Newlib did work fine for me in my own development environment. But for people with less tool experiences it is not that easy to work with newlib. Hence I have dropped newlib and with great help from @rsta2 I have implemented the needed C functions.
from circle.
Thanks @rsta2 and @vanvught for all the support and quick replies. All the information you guys provided was really very helpful and it cleared a lot of queries I had. For time being I'm able to implement and run basic mathematical functions that I require for my application. Hopefully I'll get the things running the way I intend to on the raspberry pi.
from circle.
I have made some inital experiments to port newlib to Circle. For a first attempt I wanted to leave the system calls unimplemented, and in a second step I wanted to implement the write() and open() system calls based on the SD card class of Circle. Here are some of my findings:
-
As @vanvught pointed out, Circle already has malloc() and free(). There is an option for building newlib with externally supplied memory management routines. To make this work, one would have to implement realloc() and calloc() on the Circle side.
-
Parts of the standard C library are already implemented in Circle. In my experimental build this gave errors because of duplicate symbols. It would require modifications in Circle, for example a build time option with #ifdefs that disables Circle's C library functions, to resolve this. Another option would be to disable these functions in newlib, but this looks more complicated and probably less maintainable to me.
-
With disabling the C library functions in Circle there would be a circular dependency if certain newlib system calls were implemented based on Circle classes.
So as @rsta2 already pointed out porting a C library to a bare-metal system is non-trivial, and while newlib looks like a much better option than the GNU C library it is still not a straightforward story...
from circle.
Related Issues (20)
- AARCH64 bootloader and unaligned memory access HOT 4
- aarch64-none-elf-g++: fatal error: '-fuse-linker-plugin', but liblto_plugin.so not found compilation terminated. HOT 5
- Pi Zero 2 W failing to Initialize WLAN HOT 2
- CTimer delays busy-spin the processor HOT 2
- Advice Needed: REST framework HOT 1
- release-45.2 usb samples compile with errors HOT 2
- TCP Connection in Interrupt HOT 2
- I2C feature request: add support for repeated start HOT 6
- USB CDC/ACM gadget HOT 19
- GetClockTicks without wrap HOT 3
- GPU support on Raspi 4 HOT 4
- Circle linker failure with softfp HOT 2
- Make USB gadget vendor and device strings configurable HOT 2
- Support for touchscreens with additional reports in HID descriptor HOT 7
- Question about log when testing with Qemu HOT 2
- Help with setting PREFIX HOT 4
- Question: Waveshare 5'' DSI display support? HOT 2
- Waveshare 15.6inch Capacitive Touch Screen HOT 2
- Can I run OpenCV? HOT 2
- Sample "07-usbstorage" fails with Pi5 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circle.