简体   繁体   English

如何为window构建一个基于linux的程序?

[英]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:在这种情况下,您的选择实际上是:

  1. 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.但是,它也可能同样不是,在这种情况下,您必须做一些工作。

  2. 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.

相关问题 基于Linux的固件,如何实现更新的好方法? - Linux-Based Firmware, how to implement a good way to update? 在基于Linux的WAGO PFC200 PLC上与CoDeSys程序通信 - Communicate with CoDeSys program on a Linux-based WAGO PFC200 PLC 在基于 Linux 的发行版上签署 Windows 应用程序 - Signing Windows application on Linux-based distros 通过调制解调器连接到基于 Linux 的服务器 - Connecting to a Linux-based server over a modem 基于Linux的域管理解决方案? - Linux-based solution for domain management? 基于Linux的RDBMS,用于偶尔连接的复制 - Linux-based RDBMS for Occasionally Connected Replication 如何在Docker Hub中过滤基于Windows或Linux的容器? - How can I filter on Windows-based or Linux-based containers within Docker Hub? 如何提高在 Windows 10 上运行 R 脚本的基于 Linux 的 Docker 桌面容器的性能? - How can I improve the performance of Linux-based Docker Desktop containers running R scripts on Windows 10? 将Oulook / Exchange任务与基于Linux的Rails集成 - Integrating Oulook/Exchange Tasks with Linux-based Rails 基于 Linux 的系统上类似 Dropbox 的自动文件版本控制 - Dropbox-like automatic file versioning on Linux-based systems
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM