C++ 需要运行时吗?
为什么有些 C++ 项目需要安装运行时包,而另一些则不需要?
编辑:如何使项目在没有运行时的情况下工作?
Why do some C++ projects require a runtime package to be installed, while others do not?
EDIT:How to make a project to work without the runtime?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有些是静态链接的,而另一些则依赖于在运行时加载的动态库。 要静态链接您自己的项目,您需要更改项目配置 - 如何执行此操作取决于您正在使用的编译器/链接器和/或 IDE。
Some will have been statically linked, while others will depend on a dynamic library, loaded at run-time. To link your own project statically, you need to change your project configuration - how you do this depends on the compiler/linker and/or IDE you are using.
一些应用程序是通过与系统库链接而构建的,这就是动态链接程序。
其他程序将库代码包含到可执行文件中,这是静态链接程序。
动态链接的优点:
动态链接的缺点:
静态链接的优点:
静态链接的缺点:
要获取静态项目,您需要在项目属性中设置该选项。
Some applications are built linking with the system libraries this are the dynamic linked programs.
Other programs contains the code of the libraries into the executable file this are the static linked programs.
Pros of dynamic linked:
Cons of dynamic linked:
Pros of static linked:
Cons of static linked:
To get a static project you need to set up the option in the project properties.
我认为这是指VS2005 service pack 1运行时。 由于某种原因,MS 添加了一些非向后兼容的功能,因此任何使用 VS2005sp1 构建的应用程序都需要运行时。
I think this refers to the VS2005 service pack 1 runtime. For some reason MS added some non-backward compatible features to it, so any app built with VS2005sp1 requires the runtime to go with it.
如果您使用作为 DLL(而不是静态库)链接的标准 C/C++ 库,则需要安装运行时包。 因此,避免这种情况的一种方法是静态链接标准 C/C++ 库(C++ 项目设置)。 对于您的情况来说,这可能是可能的,也可能是不可能的。
如果没有,您可以使用 Visual Studio 发行版中的 dependency walker 工具来识别应用程序所需的 DLL,并将它们放在可执行文件附近。
您应该注意的是,在 Visual Studio 2005 及更高版本中,二进制文件的清单可能(并且可能会:)让您的生活变得更加困难。 特别是自从 Visual Studio 2005 SP1 更改了 C++ 库的版本以及清单以来。
You need to have runtime package installed in case you are working with standard C/C++ library linked as DLL, and not as static library. So one way to avoid it is to link standard C/C++ library statically (C++ project settings). It may, or may not be possible in your case.
If not, you can use dependency walker tool from Visual Studio distribution to identify the DLLs needed by your application and just put them near your executable.
What you should be aware in Visual Studio 2005 and later is that there are the manifests for binaries can (and probably will :) make your life harder. Specially since SP1 for Visual Studio 2005 changes the version of C++ library, and the manifests as well.