编译独立exe与Cygwin [英] Compile stand alone exe with Cygwin

查看:203
本文介绍了编译独立exe与Cygwin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用cygwin做一个独立的exe。我有两个选项:

I want to make a stand-alone exe with cygwin. I have two options:


  1. 静态链接cygwin1.dll

    如果我可以静态链接cygwin1.dll ,那么我可以得到一个独立的exe。

  1. Staticly link cygwin1.dll
    If I can statically link cygwin1.dll, then I can get a stand-alone exe.

合并cygwin1.dll和myprog.exe

如果我可以将cygwin1.dll与我的程序合并, - 独家exe。

Merge cygwin1.dll with myprog.exe
If I can merge cygwin1.dll with my program, the I can get a stand-alone exe.

不建议我使用IlMerge。

我没有用.NET编译我的程序。

这些选项是否可能?如果没有,这个困境有什么可能吗? Thanx!

Are any of these options possible? If not, is there anything that is possible with this dilemma? Thanx!

推荐答案

我可以看到你可能认为合理的两种可能性。一个是使用不同的编译器(例如,MinGW - 无论什么,只是因此它不需要cygwin)构建一个存根可执行文件,将主可执行文件和cygwin.dll解压到一个临时目录中,然后生成该可执行文件。要仅分发单个可执行文件,您需要将主可执行文件和cygwin.dll添加到stub作为二进制资源。这是一个有点丑,但很简单。

I can see two possibilities that you might consider reasonable. One would be to build a stub executable with a different compiler (e.g., MinGW -- whatever, just so it doesn't need cygwin) to unpack the main executable and cygwin.dll into a temporary directory, and then spawn that executable. To distribute only a single executable, you'd want to add the main executable and cygwin.dll to the "stub" as binary resources. It's a bit ugly, but pretty straightforward.

另一种方法是抓住 source to cygwin ,并将其构建为静态库。至少在理论上,这应该更清洁 - 但它也毫无疑问更多的工作。让它构建为纯静态代码而不是DLL几乎肯定需要一些工作,虽然很难甚至猜测多少。只是浏览一下,它似乎不太可能,这将是一个快速的工作几个小时,或任何类似的东西(除非有一些我错过,当然已经支持静态建立)。

The alternative would be to grab the source to cygwin, and build it as a static library. At least in theory, this should be cleaner -- but it's also undoubtedly more work. Getting it to build as purely static code instead of a DLL will almost certainly take some work, though it's hard to even guess how much. Just browsing a bit, it's seems pretty unlikely that it's going to be a quick job of a couple hours, or anything like that (unless there's something there that I missed that already supports building it statically, of course).

这篇关于编译独立exe与Cygwin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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