删除dll中对CRT的依赖
我正在 Visual Studio 2010 上构建一个 dll,并使用一些简单的 C 函数,例如 fprintf
和 fread
,它链接到 msvcr100.dll< /代码> 默认情况下。
该 dll 将被加载到可能使用不同 CRT 版本的应用程序中(例如 msvcr90.dll
、msvcrt.dll
)。
由于我知道应用程序将在加载 dll 之前加载 CRT,因此我可以删除对 msvcr100.dll
的依赖并使用应用程序加载的 CRT 中的 C 函数吗?
I'm building a dll on Visual Studio 2010, and I'm using some simple C functions like fprintf
and fread
, and it's linking to msvcr100.dll
by default.
This dll is going to be loaded into an app that may be using a different CRT version (eg. msvcr90.dll
, msvcrt.dll
).
Since I know the app's going to load a CRT before my dll gets loaded, can I remove the dependency on msvcr100.dll
and use the C functions in the CRT loaded by the app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我决定根据目标应用程序使用的最低公分母 CRT 版本
msvcr90.dll
构建 DLL。我通过使用 Visual C++ 2008 Express(免费)中提供的 MSVC 工具链来完成此操作。
我确实尝试了 mingw/gcc 工具链,它允许您指定要链接的 CRT 版本(请参阅 mingw-rt 和 gcc -specs=msvcr**),但是,
msvcr90.dll
是一种新型 SxS 程序集,因此我无法使生成的可执行文件正常运行。可能值得考虑完全跳过对
msvcr**.dll
的链接;请参阅这篇文章和VC/include/delayhlp.cpp
。In the end, I decided to build the DLL against the lowest common denominator CRT version used by the target app,
msvcr90.dll
.I did this by using the MSVC toolchain, available with Visual C++ 2008 Express (free).
I did try the mingw/gcc toolchain, which allows you to specify which CRT version to link against (see mingw-rt and gcc -specs=msvcr**), however,
msvcr90.dll
is a new-style SxS assembly so I couldn't get the produced executable to run properly.It may be worth considering skipping linking against
msvcr**.dll
entirely; see this post andVC/include/delayhlp.cpp
.