How do you create a freestanding C++ program?

后端 未结 7 921
予麋鹿
予麋鹿 2021-02-02 02:11

I\'m just wondering how you create a freestanding program in C++?

Edit: By freestanding I mean a program that doesn\'t run in a hosted envrioment (eg.

7条回答
  •  不知归路
    2021-02-02 02:31

    You will need an environment that provides:

    • A working C library, or enough of it to do what you want
    • The parts of the C++ runtime that you intend to use. This is compiler-specific

    In addition to any other libraries. If you have no dynamic linker on your platform (if you have no OS, you probably have no linker) then you will have to static-link it all.

    In practice this means linking some small C++ runtime, and a C library appropriate for your platform. Then you can simply write a standalone C++ program.

提交回复
热议问题