我应该选择哪个 VC++ 运行时版本 - 静态还是动态? [英] Which VC++ runtime version do I choose - static or dynamic?

查看:30
本文介绍了我应该选择哪个 VC++ 运行时版本 - 静态还是动态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 64 位进程内 VC++ ATL COM 服务器,它基本上只是将所有调用重定向到一个进程外 COM 服务器.所以我的COM服务器基本上什么都不做.

I'm developing a 64-bit in-proc VC++ ATL COM server that basically just redirects all calls to an out-proc COM server. So my COM server basically does nothing.

最初它在 DLL 中使用 C++ 运行时(/MD 编译器开关).我注意到当我在干净的 64 位 Win2k3 regsvr32 上部署它时失败并显示错误:LoadLibrary({fileName}) failed – 由于应用程序配置不正确,此应用程序无法启动.重新安装应用程序可能会解决此问题.

Initially it used the C++ runtime in a DLL (/MD compiler switch). I've noticed that when I deploy it on a clean 64-bit Win2k3 regsvr32 fails with an error: LoadLibrary({fileName}) failed – This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

Google 提供帮助 - 问题在于未安装 VC++9 运行时.即使 msvcr90.dll 与我的 COM 服务器位于同一目录中,问题仍然存在.我猜这是因为搜索依赖库的工作方式 - 它不会查看同一个目录,我需要 WindowsSystem32 或类似目录中的 msvcr90.dll.由于这对我的部署来说是一个复杂的问题,我转而使用静态链接的 C++ 运行时(/MT 编译器开关).现在它部署得很好..dll 文件的大小只有 110k(以前是 45k),所以我不介意.

Google helps - the problem is that VC++9 runtime is not installed. The problem persists even when msvcr90.dll is in the same directory as my COM server. That as I guess is because of how search for dependent libraries works - it doen't look into the same directory and I need the msvcr90.dll in WindowsSystem32 or the like. Since this is a complication to my deployment I switched to using the statically linked C++ runtime (/MT compiler switch). Now it deploys fine. The size of the .dll file is 110k only (was 45k) so it doesn't bother me.

现在我听说了很多关于在一个进程中混合不同版本的 C++ 运行时是多么糟糕的事情——CRT 状态可能会被破坏,地狱可能会崩溃等等.我是否必须考虑这一点并期望将/MD 更改为/MT 会出现问题,尤其是因为我不知道 COM 服务器使用者使用的是哪个版本?

Now I've heard a lot about how bad it is to mix different versions of C++ runtime in one process - CRT state can be broken, hell can break loose and so on. Do I have to think of this and expect problems from changing /MD to /MT especially since I don't know what version the COM server consumers are using?

推荐答案

据我所知,从 VS2005 开始,VS 中不推荐使用静态运行时.

As far as I know the Static runtime is deprecated in VS since VS2005.

问题在于 Visual C 运行时是一个并排的 dll.也就是说,它必须从 c:windowswinsxs 目录加载.这就是为什么将其放在同一目录中不再有效的原因.

The problem is that the Visual C Runtime is a side by side dll. That is it must be loaded from the c:windowswinsxs directory. This is why placing it in the same directory is no longer works.

正确的解决方案是在客户端系统上安装正确的 CRT 可再发行组件.

The correct solution is to install the correct CRT redistributable on the client system.

参见 http://msdn.microsoft.com/en-us/library/ms235316.aspx 了解更多信息

这可能是正确的可再发行版:http://www.microsoft.com/downloads/details.aspx?familyid=BD2A6171-E2D6-4230-B809-9A8D7548C1B6&displaylang=en

This might be the correct redistributable: http://www.microsoft.com/downloads/details.aspx?familyid=BD2A6171-E2D6-4230-B809-9A8D7548C1B6&displaylang=en

安装正确的 dll 会将运行时 dll 放在 winsxs 目录中.

Installing the correct one will place the runtime dlls in the winsxs directory.

这篇关于我应该选择哪个 VC++ 运行时版本 - 静态还是动态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆