[英]how to build a linux-based program for window?
I want to build a inux-based program fully standalone for windows.我想为 Windows 构建一个完全独立的基于 inux 的程序。 And I try to use mingw64 on ubuntu with the command
我尝试使用命令在 ubuntu 上使用 mingw64
./configure --host=x86_64-w64-mingw32 --disable-shared --enable-static LDFLAGS="-L /usr/local/lib/"
make
But it failed with但它失败了
src/libcork/posix/subprocess.c:14:24: fatal error: sys/select.h: No such file or directory
#include <sys/select.h>
^
compilation terminated.
Here is the source code in github: https://github.com/shadowsocks/simple-obfs这里是github中的源代码: https : //github.com/shadowsocks/simple-obfs
So how can I build the program fully standalone for windows?那么如何为 Windows 构建完全独立的程序呢? May I try the cygwin or msys2?
我可以试试 cygwin 或 msys2 吗?
update:更新:
I find another source code which has been ported.我找到了另一个已移植的源代码。 But when I compiled it with
但是当我编译它时
./configure --host=x86_64-w64-mingw32 CFLAGS="-static" LDFLAGS="-static"
I get an executable file which still needs the libssp-0.dll
.我得到一个仍然需要
libssp-0.dll
的可执行文件。
So how can I make the libssp
be static linked?那么如何使
libssp
静态链接?
Here is the new source code: https://github.com/Windendless/simple-obfs这是新的源代码: https : //github.com/Windendless/simple-obfs
I don't think that the functionality in select.h
is available on the MinGW version of gcc, because it is not available in the Windows platform.我认为
select.h
中的功能在 gcc 的 MinGW 版本上不可用,因为它在 Windows 平台上不可用。 If you're building something that was intended to be built on Windows, then you might find that there are options you can pass to configure
that enable a different, Windows-friendly way of achieving the same thing.如果您正在构建打算在 Windows 上构建的东西,那么您可能会发现可以传递给
configure
选项,以启用不同的、对 Windows 友好的方式来实现相同的目标。 If you're building something that was only really intended to be used on Linux, then you might be out of luck.如果您正在构建仅真正打算在 Linux 上使用的东西,那么您可能就不走运了。 In that case, your choices really amount to:
在这种情况下,您的选择实际上是:
Modify the code so it doesn't require select.h
.修改代码,使其不需要
select.h
。 Some of that functionality might already exist in the Windows Sockets API, with a somewhat different implementation.其中一些功能可能已经存在于 Windows Sockets API 中,但实现方式略有不同。 However, it might equally well not, in which case you'll have to do some work.
但是,它也可能同样不是,在这种情况下,您必须做一些工作。
Use a Windows compatibility layer that is more feature-rich than MinGW.使用比 MinGW 功能更丰富的 Windows 兼容层。 Cygwin might well work, as might the Windows Subsystem for Linux in Windows 10. However, none of these approaches amounts to building a "standalone" application, because they require some supporting infrastructure.
Cygwin 可能会很好地工作,就像 Windows 10 中的适用于 Linux 的 Windows 子系统一样。但是,这些方法都不是构建“独立”应用程序,因为它们需要一些支持基础设施。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.