I'm writing an OS for microcontrollers and I'd like to run it on some architectures, so I want to make it very easy to port. Also, I want to write just the kernel of the OS. I intend to use open source software to make every other component of the system. I'll use a free implementation of the C Standard Library and I intend to use the free libraries of peripheral drivers provided by the microcontrollers vendors instead of writing my own drivers.
The big problem here is that the C compiler for each microcontroller usually comes with peripherals drivers and a minimal implementation of the C Standard Library. So I'll need to add a more complete implementation of the C Standard Library in my project. But then I'll have conflicts between the two implementations.
I could just turn off the C Library that comes with the compiler, keeping just the peripheral drivers part. But I don't know how to do that. Is it possible?
What I think I can do is to download everything (C Standard Library, Microcontroller's Library), add them to my project's folder and edit them to fit my needs. That is an alternative but I don't know if it is the best one.
As this is a forum with lots of experienced OS programmers I think someone could give me some directions.
Should I just download everything and include it in my project's folder or should I keep compiler's library code in its own directory and try to make this two pieces of code work together somehow?
How to incorporate thirdy-party libraries into my OS?
- igorov70
- Posts: 11
- Joined: Sun Mar 25, 2018 10:35 am
- Libera.chat IRC: i dont have
- Location: Exchange student in Moscow
Re: How to incorporate thirdy-party libraries into my OS?
You not want rely so hard on C library in OS project.
Re: How to incorporate thirdy-party libraries into my OS?
Well, you obviously want a C library when you want to write user programs for the OS.igorov70 wrote:You not want rely so hard on C library in OS project.
But you can't just use third-party libraries. You'll have to port them to your OS, using the source code. How easy this is depends upon how closely your OS imitates the OS those libraries were written for.
- max
- Member
- Posts: 616
- Joined: Mon Mar 05, 2012 11:23 am
- Libera.chat IRC: maxdev
- Location: Germany
- Contact:
Re: How to incorporate thirdy-party libraries into my OS?
That's harder than you think. You need a cross compiler. That cross compiler needs the C standard headers of your target platform. Your target platform doesn't really exist yet, though. So you have a kind of chicken-and-egg-problem there.igorov70 wrote:You not want rely so hard on C library in OS project.
- igorov70
- Posts: 11
- Joined: Sun Mar 25, 2018 10:35 am
- Libera.chat IRC: i dont have
- Location: Exchange student in Moscow
Re: How to incorporate thirdy-party libraries into my OS?
I used #define for my microcontrollers when ported code amongst them. So if no function was present, i implemented it and turned it on with ifdefs. Good and fast trade off.max wrote:That's harder than you think. You need a cross compiler. That cross compiler needs the C standard headers of your target platform. Your target platform doesn't really exist yet, though. So you have a kind of chicken-and-egg-problem there.igorov70 wrote:You not want rely so hard on C library in OS project.