C/ c++运行时库和C/ c++标准库的区别

时间:2021-03-02 13:19:41

Can you guys tell me the difference between them?

你们能告诉我他们之间的区别吗?

By the way, is there something called C++ library or C library?

顺便问一下,有c++库还是C库?

7 个解决方案

#1


26  

The C++ Standard Library and C Standard Library are the libraries that the C++ and C Standard define that is provided to C++ and C programs to use. That's a common meaning of those words, i haven't ever seen another definition of it, and C++ itself defines it as this:

c++标准库和C标准库是c++和C标准定义的库,提供给c++和C程序使用。这是这些词的一个常见含义,我从未见过它的另一个定义,c++本身将它定义为:

The C++ Standard Library provides an extensible framework, and contains components for: language support, diagnostics, general utilities, strings, locales, containers, iterators, algorithms, numerics, and input/output. The language support components are required by certain parts of the C++ language, such as memory allocation (5.3.4, 5.3.5) and exception processing (clause 15).

c++标准库提供了一个可扩展的框架,并包含以下组件:语言支持、诊断、通用实用程序、字符串、地区、容器、迭代器、算法、数字符号和输入/输出。c++语言的某些部分需要语言支持组件,比如内存分配(5.3.4,5.3.5)和异常处理(第15条)。

C++ Runtime Library and C Runtime Library aren't so equally used. Some say a runtime library is the part that a program uses at runtime (like, the code that implements std::type_info or the code supporting signal handlers) as opposed to stuff that they only use at compile time (like macro definitions). Other people say that a runtime library is one that is linked to a program at load time dynamically, as opposed to statically at compile time, though this use is very seldom. shared library or dynamically linked library are better terms for that.

c++运行时库和C运行时库的使用并不相同。有人说,运行时库是程序在运行时使用的部分(比如,实现std::type_info的代码或支持信号处理程序的代码),而不是它们只在编译时使用的东西(比如宏定义)。另一些人说,运行时库是在加载时动态地链接到程序的库,而不是在编译时静态地链接到程序,尽管这种使用很少。共享库或动态链接库是更好的术语。

C++ Library and C Library are very broad terms. They just mean that a library is written in C++ and/or C.

c++库和C库是非常宽泛的术语。它们只是意味着一个库是用c++和/或C编写的。

The above is not only limited to C++ and/or C. There are python libraries and there is a python Standard Library too.

以上内容不仅局限于c++和/或C,还有python库和python标准库。

#2


10  

C++ standard library is a term to define the standard library that a minimum conforming compiler/toolset should have. C++ runtime library is the library shipped with the toolset to provide standard library functionality, and probably some internal stuff the compiler might need. In fact, those terms are often interchangeable.

c++标准库是定义标准库的术语,标准库是一个符合标准的最小编译器/工具集应该具有的。c++运行时库是随工具集一起提供的库,用于提供标准的库功能,以及编译器可能需要的一些内部功能。事实上,这些术语通常是可以互换的。

#3


10  

According to https://en.wikibooks.org/wiki/C_Programming/Standard_libraries#Common_support_libraries, there is a very important difference between Standard Library and Runtime Library. While the Standard Library defines functions that are (always) available to the programmer (but not part of the (initial) specification of the programming language, at least in C), the Runtime Library contains functions that are necessary to actually run a program on a given platform (and are platform-specific / vendor-specific).

根据https://en.wikibooks.org/wiki/C_Programming/Standard_libraries#Common_support_libraries,标准库和运行库之间有一个非常重要的区别。虽然标准库定义的函数(总是)对程序员可用(但不是编程语言(至少在C中)的(初始)规范的一部分),但是运行时库包含的函数对于在给定平台上实际运行程序是必要的(并且是特定于平台/供应商特定的)。

For example, printf() is part of the C Standard Library, while program startup (which is in many cases invisible to the programmer) is implemented in the Runtime Library. So for example, you could write a C-program which does not use the Standard Library but you always need the Runtime Library because otherwise, your program could not be executed. But to be honest, this would be of little use because a C-program without the Standard Library could not do input/output so it could not tell you something about its impressive results.

例如,printf()是C标准库的一部分,而程序启动(在许多情况下,程序员看不到)是在运行时库中实现的。例如,你可以编写一个不使用标准库的c程序,但是你总是需要运行时库,否则,你的程序就无法执行。但老实说,这没什么用,因为没有标准库的c程序不能输入/输出,所以它不能告诉你一些令人印象深刻的结果。

What leads to confusion concerning the difference between those two is:

导致混淆这两者之间的区别的是:

  1. In every case, the Runtime Library is needed/used and in (nearly) all cases, the Standard Library is used. Furthermore, the Standard Library could be dependent on the Runtime Library and is most probably developed by the same vendor. Therefore, the distinction is not clear and in most cases not necessary.
  2. 在每种情况下,都需要/使用运行时库,并且(几乎)在所有情况下,都使用标准库。此外,标准库可能依赖于运行时库,而且很可能是由同一供应商开发的。因此,这种区别并不明确,在大多数情况下是不必要的。
  3. Microsoft has put the C Standard Library and C Runtime Library together and just calls it C Run-Time Library.
  4. 微软将C标准库和C运行时库放在一起,并称之为C运行时库。

#4


5  

Introduction

C/C++ Standard Library is any implementation of all the required set of functionalities needed to accomplish what ISO C/C++ standard requires. (Wikipedia definition of a C++ Standard Library)

C/ c++标准库是实现ISO C/ c++标准所需要的所有功能的任何实现。(Wikipedia定义的c++标准库)

A Runtime Library is any implementation of a set of functionalities that are usually offered in form of SDK that are required to be installed or statically linked to let a program using that SDK to be run having all that it could need to use that SDK. For these reasons Runtime Library is usually strictly related to the SDK used and the compiler version used. (Wikipedia definition of a generic Runtime Library)

运行时库是一组功能的实现,这些功能通常以SDK的形式提供,需要安装或静态链接,以让使用该SDK的程序能够运行,并具有使用该SDK所需的所有功能。由于这些原因,运行时库通常与所使用的SDK和所使用的编译器版本严格相关。(Wikipedia定义通用运行时库)

C/C++ Runtime Library

A C/C++ Runtime Library has thus to contain all the functionalities required to execute what is required by the Standard Library (header only functionalities of the specific Standard Library implementation can be excluded because they are resolved within the program itself) plus a set of functionalities offered by the SDK of the specific implementation (again functionalities offered as header only can be excluded).

一个C / c++运行时库从而包含所有所需的功能执行所要求的标准库(头只有特定的标准库实现的功能可以被排除在外,因为他们解决在程序本身)+ SDK提供的一组功能的具体实现(功能作为头只能被排除在外)。

The Microsoft Case

Before MSVC140: recent Microsoft VC++ Runtime used to have an installable version of the C/C++ Runtime (VCRedist), that version was the same for all the OSes.

在MSVC140之前:最近的Microsoft vc++运行时曾经有一个可安装的C/ c++运行时(VCRedist),这个版本对于所有的操作系统来说都是一样的。

Starting from MSVC140: starting from the next MSVC140 compiler, the Runtime library has been split into two parts:

从MSVC140开始:从下一个MSVC140编译器开始,运行时库被分成两个部分:

  • UCRT (Universal C Runtime): shipped with the OS and related to it, distributed through updates or OS images
  • UCRT (Universal C Runtime):随操作系统一起发布,并与之相关,通过更新或操作系统映像进行分发
  • VCRedist: the part that is expected to change with the compiler being used and that is common among the different OSes versions (managed like before MSVC140).
  • VCRedist:预期会随使用的编译器而更改的部分,这在不同的os版本中是常见的(类似于MSVC140之前的管理)。

Here is a link to MS C Runtime reference documentation. Here is a link to MS C Runtime download page and install instructions.

这里有一个到MS C运行时参考文档的链接。这里有一个链接到MS C运行时下载页面和安装说明。

#5


2  

C++ Standard Library consists of two main parts, namely the Standard Template Library (STL) and the runtime library. STL is implemented in header files only, while an implementation of the runtime library contains both header files and binaries (i.e., .lib and .dll files on Windows platforms).

c++标准库包括两个主要部分,即标准模板库(STL)和运行时库。STL只在头文件中实现,而运行时库的实现同时包含头文件和二进制文件(例如。Windows平台上的.lib和.dll文件)。

#6


1  

C++ runtime library contains functions and objects supplied in C++, such as cout, fstream and so on.

c++运行时库包含用c++提供的函数和对象,如cout、fstream等。

C runtime library contains C functions such as printf, scanf, fopen, and so on.

C运行时库包含诸如printf、scanf、fopen等C函数。

#7


1  

The standard library is a particular set of defined names and headers as defined in the C++ standard document, a runtime library is a blob of binary stuff that is used as a part of the compiled program but is not included in your program executables because it is so commonly needed.

标准库是一组特定的名称和标题定义为c++标准中定义的文档,一个运行时库是一个blob的二进制的东西作为编译程序的一部分,但不包括在您的程序的可执行文件,因为它是如此的普遍需要。

Instead, those pieces of functionality are included on the host machine (although you might need to ask your customers to install an updated runtime if they have an older service pack) so they get included into your program only at "runtime".

相反,这些功能都包含在主机上(尽管如果客户有一个较旧的服务包,您可能需要要求他们安装一个更新的运行时),因此它们只在“运行时”才被包含到您的程序中。

Ref. links:

引用链接:

http://msdn2.microsoft.com/en-us/library/cscc687y(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/cscc687y(VS.80). aspx

http://msdn2.microsoft.com/en-us/library/59ey50w6(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/59ey50w6(VS.80). aspx

#1


26  

The C++ Standard Library and C Standard Library are the libraries that the C++ and C Standard define that is provided to C++ and C programs to use. That's a common meaning of those words, i haven't ever seen another definition of it, and C++ itself defines it as this:

c++标准库和C标准库是c++和C标准定义的库,提供给c++和C程序使用。这是这些词的一个常见含义,我从未见过它的另一个定义,c++本身将它定义为:

The C++ Standard Library provides an extensible framework, and contains components for: language support, diagnostics, general utilities, strings, locales, containers, iterators, algorithms, numerics, and input/output. The language support components are required by certain parts of the C++ language, such as memory allocation (5.3.4, 5.3.5) and exception processing (clause 15).

c++标准库提供了一个可扩展的框架,并包含以下组件:语言支持、诊断、通用实用程序、字符串、地区、容器、迭代器、算法、数字符号和输入/输出。c++语言的某些部分需要语言支持组件,比如内存分配(5.3.4,5.3.5)和异常处理(第15条)。

C++ Runtime Library and C Runtime Library aren't so equally used. Some say a runtime library is the part that a program uses at runtime (like, the code that implements std::type_info or the code supporting signal handlers) as opposed to stuff that they only use at compile time (like macro definitions). Other people say that a runtime library is one that is linked to a program at load time dynamically, as opposed to statically at compile time, though this use is very seldom. shared library or dynamically linked library are better terms for that.

c++运行时库和C运行时库的使用并不相同。有人说,运行时库是程序在运行时使用的部分(比如,实现std::type_info的代码或支持信号处理程序的代码),而不是它们只在编译时使用的东西(比如宏定义)。另一些人说,运行时库是在加载时动态地链接到程序的库,而不是在编译时静态地链接到程序,尽管这种使用很少。共享库或动态链接库是更好的术语。

C++ Library and C Library are very broad terms. They just mean that a library is written in C++ and/or C.

c++库和C库是非常宽泛的术语。它们只是意味着一个库是用c++和/或C编写的。

The above is not only limited to C++ and/or C. There are python libraries and there is a python Standard Library too.

以上内容不仅局限于c++和/或C,还有python库和python标准库。

#2


10  

C++ standard library is a term to define the standard library that a minimum conforming compiler/toolset should have. C++ runtime library is the library shipped with the toolset to provide standard library functionality, and probably some internal stuff the compiler might need. In fact, those terms are often interchangeable.

c++标准库是定义标准库的术语,标准库是一个符合标准的最小编译器/工具集应该具有的。c++运行时库是随工具集一起提供的库,用于提供标准的库功能,以及编译器可能需要的一些内部功能。事实上,这些术语通常是可以互换的。

#3


10  

According to https://en.wikibooks.org/wiki/C_Programming/Standard_libraries#Common_support_libraries, there is a very important difference between Standard Library and Runtime Library. While the Standard Library defines functions that are (always) available to the programmer (but not part of the (initial) specification of the programming language, at least in C), the Runtime Library contains functions that are necessary to actually run a program on a given platform (and are platform-specific / vendor-specific).

根据https://en.wikibooks.org/wiki/C_Programming/Standard_libraries#Common_support_libraries,标准库和运行库之间有一个非常重要的区别。虽然标准库定义的函数(总是)对程序员可用(但不是编程语言(至少在C中)的(初始)规范的一部分),但是运行时库包含的函数对于在给定平台上实际运行程序是必要的(并且是特定于平台/供应商特定的)。

For example, printf() is part of the C Standard Library, while program startup (which is in many cases invisible to the programmer) is implemented in the Runtime Library. So for example, you could write a C-program which does not use the Standard Library but you always need the Runtime Library because otherwise, your program could not be executed. But to be honest, this would be of little use because a C-program without the Standard Library could not do input/output so it could not tell you something about its impressive results.

例如,printf()是C标准库的一部分,而程序启动(在许多情况下,程序员看不到)是在运行时库中实现的。例如,你可以编写一个不使用标准库的c程序,但是你总是需要运行时库,否则,你的程序就无法执行。但老实说,这没什么用,因为没有标准库的c程序不能输入/输出,所以它不能告诉你一些令人印象深刻的结果。

What leads to confusion concerning the difference between those two is:

导致混淆这两者之间的区别的是:

  1. In every case, the Runtime Library is needed/used and in (nearly) all cases, the Standard Library is used. Furthermore, the Standard Library could be dependent on the Runtime Library and is most probably developed by the same vendor. Therefore, the distinction is not clear and in most cases not necessary.
  2. 在每种情况下,都需要/使用运行时库,并且(几乎)在所有情况下,都使用标准库。此外,标准库可能依赖于运行时库,而且很可能是由同一供应商开发的。因此,这种区别并不明确,在大多数情况下是不必要的。
  3. Microsoft has put the C Standard Library and C Runtime Library together and just calls it C Run-Time Library.
  4. 微软将C标准库和C运行时库放在一起,并称之为C运行时库。

#4


5  

Introduction

C/C++ Standard Library is any implementation of all the required set of functionalities needed to accomplish what ISO C/C++ standard requires. (Wikipedia definition of a C++ Standard Library)

C/ c++标准库是实现ISO C/ c++标准所需要的所有功能的任何实现。(Wikipedia定义的c++标准库)

A Runtime Library is any implementation of a set of functionalities that are usually offered in form of SDK that are required to be installed or statically linked to let a program using that SDK to be run having all that it could need to use that SDK. For these reasons Runtime Library is usually strictly related to the SDK used and the compiler version used. (Wikipedia definition of a generic Runtime Library)

运行时库是一组功能的实现,这些功能通常以SDK的形式提供,需要安装或静态链接,以让使用该SDK的程序能够运行,并具有使用该SDK所需的所有功能。由于这些原因,运行时库通常与所使用的SDK和所使用的编译器版本严格相关。(Wikipedia定义通用运行时库)

C/C++ Runtime Library

A C/C++ Runtime Library has thus to contain all the functionalities required to execute what is required by the Standard Library (header only functionalities of the specific Standard Library implementation can be excluded because they are resolved within the program itself) plus a set of functionalities offered by the SDK of the specific implementation (again functionalities offered as header only can be excluded).

一个C / c++运行时库从而包含所有所需的功能执行所要求的标准库(头只有特定的标准库实现的功能可以被排除在外,因为他们解决在程序本身)+ SDK提供的一组功能的具体实现(功能作为头只能被排除在外)。

The Microsoft Case

Before MSVC140: recent Microsoft VC++ Runtime used to have an installable version of the C/C++ Runtime (VCRedist), that version was the same for all the OSes.

在MSVC140之前:最近的Microsoft vc++运行时曾经有一个可安装的C/ c++运行时(VCRedist),这个版本对于所有的操作系统来说都是一样的。

Starting from MSVC140: starting from the next MSVC140 compiler, the Runtime library has been split into two parts:

从MSVC140开始:从下一个MSVC140编译器开始,运行时库被分成两个部分:

  • UCRT (Universal C Runtime): shipped with the OS and related to it, distributed through updates or OS images
  • UCRT (Universal C Runtime):随操作系统一起发布,并与之相关,通过更新或操作系统映像进行分发
  • VCRedist: the part that is expected to change with the compiler being used and that is common among the different OSes versions (managed like before MSVC140).
  • VCRedist:预期会随使用的编译器而更改的部分,这在不同的os版本中是常见的(类似于MSVC140之前的管理)。

Here is a link to MS C Runtime reference documentation. Here is a link to MS C Runtime download page and install instructions.

这里有一个到MS C运行时参考文档的链接。这里有一个链接到MS C运行时下载页面和安装说明。

#5


2  

C++ Standard Library consists of two main parts, namely the Standard Template Library (STL) and the runtime library. STL is implemented in header files only, while an implementation of the runtime library contains both header files and binaries (i.e., .lib and .dll files on Windows platforms).

c++标准库包括两个主要部分,即标准模板库(STL)和运行时库。STL只在头文件中实现,而运行时库的实现同时包含头文件和二进制文件(例如。Windows平台上的.lib和.dll文件)。

#6


1  

C++ runtime library contains functions and objects supplied in C++, such as cout, fstream and so on.

c++运行时库包含用c++提供的函数和对象,如cout、fstream等。

C runtime library contains C functions such as printf, scanf, fopen, and so on.

C运行时库包含诸如printf、scanf、fopen等C函数。

#7


1  

The standard library is a particular set of defined names and headers as defined in the C++ standard document, a runtime library is a blob of binary stuff that is used as a part of the compiled program but is not included in your program executables because it is so commonly needed.

标准库是一组特定的名称和标题定义为c++标准中定义的文档,一个运行时库是一个blob的二进制的东西作为编译程序的一部分,但不包括在您的程序的可执行文件,因为它是如此的普遍需要。

Instead, those pieces of functionality are included on the host machine (although you might need to ask your customers to install an updated runtime if they have an older service pack) so they get included into your program only at "runtime".

相反,这些功能都包含在主机上(尽管如果客户有一个较旧的服务包,您可能需要要求他们安装一个更新的运行时),因此它们只在“运行时”才被包含到您的程序中。

Ref. links:

引用链接:

http://msdn2.microsoft.com/en-us/library/cscc687y(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/cscc687y(VS.80). aspx

http://msdn2.microsoft.com/en-us/library/59ey50w6(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/59ey50w6(VS.80). aspx