On 23.06.2015 1:07, Yuxin Ren wrote: > In general, what steps do I need? > I am very confused about the relationship among compiler (gcc), If you are not planning to run the compiler itself on your new OS, then it will not need to interact with that OS (anyway, if you are planning to run GCC on your OS, you'll first need to be able to cross-compile it). So, for now let's assume that you only want a C++ cross-compiler for some new target OS. > libraries (libgcc, libstdc++, libc and so on) and OS. You mentioned C++, so I suppose that you already have a working C compiler. What kind of C library does it use? newlib-based? Basically the language itself (I mean the semantics of programs which can be written in C++ even without using any libraries) requires some support from OS/libraries. In GCC the support library implementation can be found in libstdc++-v3/libsupc++. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/internals.html. For example, operators new and delete need some implementation. By default they rely on malloc/free provided by the C library. RTTI (typeid, dynamic_cast) is also implemented in libsupc++. Throwing an exception requires some mechanism which will unwind the stack and pass control to the handler. Different mechanisms are implemented in libgcc (they may require support from OS, like SEH in Windows, or some library, e.g. setjmp/longjmp functions). If your OS supports threads, you will probably need to provide some locking mechanism (mutex) to support construction of local static objects. libstdc++ uses some (well, probably quite a lot of) library functions to work with console, files (ifstream/ofstream), system time, locales, threads. And I almost certainly missed something important :) -- Regards, Mikhail Maltsev