Swift Cross编译为单个Linux二进制文件 [英] Swift cross compile to single linux binary

查看:105
本文介绍了Swift Cross编译为单个Linux二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从OS X计算机编译快速二进制文件,使其以单个二进制文件的形式在运行Linux的服务器上运行,而无需动态链接额外的库?

Is it possible to compile a swift binary from an OS X computer so that it runs on a server running Linux as a single binary without no extra libraries that need to be dynamically linked?

我在想类似将-target传递给swift命令并传递另一个参数以使其静态链接所有依赖项的方法,但是我不确定确切的命令是什么.

I'm thinking something like passing a -target to the swift command and passing another parameter to let it statically link all dependencies, but I'm not sure what the exact commands are.

-target的确切值似乎难以捉摸.

The exact value for -target seems to be rather elusive.

我是否需要知道确切的目标分布,才能将正确的字符串传递给-target参数?

Do I need to know the exact target distribution to be able to pass the correct string to the -target parameter?

推荐答案

阅读

  • 目标将是Linux
  • 计算机将为x86_64
  • 这由主要的构建脚本调用

    这是部分问题的答案

    -target的确切值似乎难以捉摸.

    The exact value for -target seems to be rather elusive.

    为Mac OSX安装可以重新定位Linux的GCC工具链,我可以看到的一个仓库是 OSXCross ,例如.

    Install a GCC toolchain for Mac OSX that can retarget Linux, one repo that I can see is OSXCross, for example.

    在运行引用该工具链的脚本之前,将环境变量的值提供给GCC.

    Supply the values to the environment variables to GCC prior to running the script, that references that toolchain.

    不幸的是,这不能保证它能正常工作,但请尝试一下看看会发生什么.

    Unfortunately, that does not guarantee it will work, but give it a try and see what happens.

    这篇关于Swift Cross编译为单个Linux二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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