简体   繁体   English

我可以静态地将MSVCRT与mingw链接吗?

[英]Can I link MSVCRT statically with mingw?

I have C program I compile with mingw on Windows. 我有C程序,我在Windows上用mingw编译。 It works fine but requires MSVCRT.DLL . 它工作正常,但需要MSVCRT.DLL I want to link that statically (like I can do in Visual Studio). 我想静态链接(就像我在Visual Studio中可以做的那样)。 Is this possible? 这可能吗?

I tried -static flag to gcc and it didn't make any change. 我尝试了-static标志到gcc ,它没有做任何改变。

What about C++ program using also standard C++ library? 使用标准C ++库的C ++程序怎么样?

I believe that MinGW doesn't use the static runtime library for copyright reasons. 我相信MinGW出于版权原因不使用静态运行时库。

You can maybe try to use newlib ( http://sourceware.org/newlib/ ) to create an executable that doesn't link to msvcrt.dll 您可以尝试使用newlib( http://sourceware.org/newlib/ )创建一个不链接到msvcrt.dll的可执行文件

Having spent a while searching for this myself, I came across this post introducing the in-progress Mingw32 Alternate C Runtime Library . 花了一段时间自己搜索这个,我发现这篇文章介绍了正在进行的Mingw32 Alternate C Runtime Library However, it's not ready for use, and the developer appears to have abandoned it. 但是,它还没有准备好使用,开发人员似乎放弃了它。 Home page link here . 主页链接在这里

Posting this answer here in the hope that it'll come in useful to people googling at some point in future. 在这里发布这个答案,希望它对将来某个时候谷歌搜索有用。

链接gcc -static -static-libgcc -static-libstdc++ ,你不需要libgcc_s_dw2-1.dlllibstdc++-6.dll

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

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