How to support C++ in a new OS

I want to get C++ support in my new operating system.
But I do not have much idea how to achieve it.
Could someone give me some guidance?
What functionality does my OS need to support? Now it has a C library, but is not compatible with Linux system call or posix API.
Does gcc have some hard dependency on some C library or system call when it compile c++ program or provide the runtime support?

Thanks a lot.
Last edited on
Last edited on
I am not trying to port gcc. I will still use gcc to compile my system in Linux.
But I want that the compiled binary can run on my OS.
It seems that gcc will put some its internal libraries in the final binary when compile C++ program, and those libraries have dependency on Linux or C library.
I do not know if this is true. And if it is true, how can I avoid or solve this problem?

Thanks a lot.
those libraries have dependency on Linux or C library.
It is actually has dependencies on target platform (OS).
So you will have to implement runtime C and C++ libraries for your OS and make gcc link to it. And, of course, implement standard library itself, so it would use your own runtime library.
Thank you very much for your help.
But I don't know exactly which library is used by gcc, maybe libgcc or libsupc++?
And how can I tell gcc link to my library instead of its own?

I don't know exactly which library is used by gcc,
https://gcc.gnu.org/onlinedocs/gcc/Standard-Libraries.html
glibc for C, libstdc++ for C++

And how can I tell gcc link to my library instead of its own?
You compile files with g++, then link it with ld, specifying your libraries. You might need to use -nostdlib switch to avoid automatic inclusion of system libraries, but you are better to read GCC specs for that.
Topic archived. No new replies allowed.