How is the C++ standard library linked to my application?

后端 未结 5 1800
情歌与酒
情歌与酒 2020-12-29 15:13

When I usually use code (include headers) from 3rd party (non-standard) C++ libraries, a pre-built binary file is linked to (or included in) the target executable that repre

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 15:59

    C and C++ runtime libraries are linked in the same way as normal libraries, the main difference is that they are usually automatically compiled against and linked by the compiler and linker with no need to specify them.

    It is incorrect however, to generalise that you don't have to ship them with your app. In most cases where you ship dynamically linked binaries you will need to include them, for example if you compile with MSVC++, you will link against whatever is installed on your build machine, if you install the dynamically linked binary on a fresh windows install, you are likely to run into problems unless you ensure the libraries are included as part of the installpack (see documentation about visual studio redistributables). The same is true on Solaris machines (standard libraries are upgraded as part of a patch set). With Linux, it's more complicated, you can't link statically due to the GPL, however the libraries are usually installed via distro packages.

提交回复
热议问题