Page 1 of 1

C++ applications

Posted: Tue Jan 26, 2010 9:12 am
by AndreaOrru
Hi all,

I've managed to make my 64-bit kernel able to load user-mode executables and to run them in multitasking. So far I'm using flat binaries, but I plan to shift to ELF sooner or later.

Even if I've developed it in C, I'd want to write user-space applications in C++. I've searched the wiki, but I've found only kernel-specific info.
What I'm supposed to do in order to use C++ in his full power for writing my programs? Even a simple list of the requirements would be appreciated.

Re: C++ applications

Posted: Tue Jan 26, 2010 9:34 am
by jal
You'll need the C++ equivalent of stdlib, to start with. STL, ATL, whatnot.


JAL

Re: C++ applications

Posted: Tue Jan 26, 2010 10:03 am
by AJ
Hi,

The first thing to start with is the standard library. Suppose this is newlib (see Porting Newlib), you will have to provide the same glue functions as if you were providing a C library for kernel space, except your glue functions will wrap system calls, rather than directly calling kernel functions.

Once you have a C library, porting the C++ stuff (such as libstdc++) should be relatively easy (coming from someone who hasn't actually done it... :) ).

Cheers,
Adam

Re: C++ applications

Posted: Tue Jan 26, 2010 10:05 am
by AndreaOrru
So I need full support to C, before anything else.
Thank you.

Re: C++ applications

Posted: Tue Jan 26, 2010 10:11 am
by Solar
andreaorru wrote:So I need full support to C, before anything else.
That's effectively true for most languages, as the majority of language support runtimes / libraries is written in C. (Or C++, at which point the snake bites its own tail.)

Luckily, C doesn't require much in the way of "support". (Which is why other languages are so often implemented in it. ;-) )

Re: C++ applications

Posted: Tue Jan 26, 2010 11:46 am
by Owen
jal wrote:You'll need the C++ equivalent of stdlib, to start with. STL, ATL, whatnot.


JAL
ATL? The ActiveX Template Library?!

:P

Re: C++ applications

Posted: Tue Jan 26, 2010 2:56 pm
by pcmattman
You need libstdc++, as has already been mentioned, but you also need to have code to run the global static constructors where present and you may also need to provide a "crti" and "crtn".
So I need full support to C, before anything else.
I'd say once you can load and run an application such as bash you are ready to get libstdc++ running with some test C++ applications.

Re: C++ applications

Posted: Wed Jan 27, 2010 1:32 am
by jal
Owen wrote:ATL? The ActiveX Template Library?!
Without the X, actually. But you are right, I was incorrect in mentioning it.


JAL