简体   繁体   English

如何更改MinGW的spec文件以链接MSVCR100.dll和MSVCP100.dll?

[英]How to change the spec file of MinGW to link against the MSVCR100.dll and MSVCP100.dll?

I'm using Windows 7 and the latest MinGW version (gcc v4.7.2). 我正在使用Windows 7和最新的MinGW版本(gcc v4.7.2)。

My problem is, to trigger MinGW to use the "MSVCR100" and the "MSVCP100" runtime dll's for a simple test application. 我的问题是,触发MinGW使用“MSVCR100”和“MSVCP100”运行时dll用于简单的测试应用程序。

My default customized spec file looks like as follows: 我的默认自定义规范文件如下所示:

%{mthreads:-lmingwthrd} -lmingw32 %{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh} -lgcc -lmoldname -lmingwex -lmsvcr100 -lmsvcp100 %{mthreads:-lmingwthrd} -lmingw32%{shared-libgcc:-lgcc_s}%{!shared-libgcc:-lgcc_eh} -lgcc -lmoldname -lmingwex -lmsvcr100 -lmsvcp100

(The mingw distribution doesn't ship any "MSVCP100.a" in the lib directory, so I've just created with the help of "dumpbin" and "dlltool" my the "MSVCP100.a" file.) (mingw发行版不会在lib目录中发送任何“MSVCP100.a”,所以我刚刚在“dumpbin”和“dlltool”的帮助下创建了我的“MSVCP100.a”文件。)

My problem is now, in case I compile my simple test application (which uses boost-date-time and boost-log), I get the following undefined references: 我现在的问题是,如果我编译我的简单测试应用程序(使用boost-date-time和boost-log),我会得到以下未定义的引用:

  • undefined reference to `gmtime' 对'gmtime'的未定义引用
  • undefined reference to `localtime' 未定义的对“localtime”的引用

But this shouldn't be possible, as in case I compile my test application with Visual Studio 2010 and analyse aftewards the binary with a dependency walker, I see, that the dll's "MSVCR100" and "MSVCP100" are referrenced. 但这不应该是可能的,例如我用Visual Studio 2010编译我的测试应用程序并使用依赖步行器分析二进制文件,我看,dll的“MSVCR100”和“MSVCP100”被引用。

Why do I need this? 我为什么需要这个? I've figured out, that my test application crashes on a Windows XP- but not on Win7 systems, as the "setlocale" function within the "msvcrt.dll" (v7.0.2600.5512) isn't thread-safe (please check the conversation between me and the boost.log maintainer regarding this issue here: 我发现,我的测试应用程序在Windows XP上崩溃,但在Win7系统上崩溃,因为“msvcrt.dll”(v7.0.2600.5512)中的“setlocale”函数不是线程安全的(请检查我和boost.log维护者之间关于此问题的对话:
Boost-Log ). Boost-Log )。 So I was curios, if my test application will also crash, in case I compile it with Visual Studio 2010 and test the binary on WinXP. 所以我很好奇,如果我的测试应用程序也会崩溃,以防我用Visual Studio 2010编译它并在WinXP上测试二进制文件。 I figured out, that no crash happens, as Vistual Studio links my test application against "MSVCR100.dll" (and MSVCP100.dll). 我发现,没有崩溃,因为Vistual Studio将我的测试应用程序与“MSVCR100.dll”(和MSVCP100.dll)链接起来。

Due to some restriction, it isn't possible to migrate my project code from MinGW to Visual Studio. 由于某些限制,无法将项目代码从MinGW迁移到Visual Studio。 So I tried to change the specs file of mingw to link against the mentioned dll's. 所以我试着改变mingw的specs文件来链接上面提到的dll。

Question: How can MinGW be triggered, to not anymore link against "msvcrt.dll", but rather to the "msvcrt100.dll"? 问题:如何触发MinGW,不再链接“msvcrt.dll”,而是“msvcrt100.dll”? Or more generally: How to trigger MinGW to use the same runtime dll's as Visual Studio does? 或者更一般地说:如何触发MinGW使用与Visual Studio相同的运行时dll?

Any help is appreciated. 任何帮助表示赞赏。 Thanks so far, 谢谢到目前为止,

Rafael 拉斐尔

Try it with: 尝试使用:

%{mthreads:-lmingwthrd} -lmingw32 %{shared-libgcc:-lgcc_s} %{!shared-libgcc:-lgcc_eh} -lgcc -lmoldname100 -lmingwex -lmsvcr100 -lmsvcp100 %{mthreads:-lmingwthrd} -lmingw32%{shared-libgcc:-lgcc_s}%{!shared-libgcc:-lgcc_eh} -lgcc -lmoldname100 -lmingwex -lmsvcr100 -lmsvcp100

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM