How to incorporate thirdy-party libraries into my OS?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rrd
Posts: 6
Joined: Wed Mar 14, 2018 8:07 am

How to incorporate thirdy-party libraries into my OS?

Post by rrd »

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?
User avatar
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?

Post by igorov70 »

You not want rely so hard on C library in OS project.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to incorporate thirdy-party libraries into my OS?

Post by iansjack »

igorov70 wrote:You not want rely so hard on C library in OS project.
Well, you obviously want a C library when you want to write user programs for the OS.

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.
User avatar
max
Member
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?

Post by max »

igorov70 wrote:You not want rely so hard on C library in OS project.
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.
User avatar
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?

Post by igorov70 »

max wrote:
igorov70 wrote:You not want rely so hard on C library in OS project.
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.
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.
Post Reply