Problems while creating a Linux-executable file from C# sourcecode using mkbundle(使用 mkbundle 从 C# 源代码创建 Linux 可执行文件时出现问题)
问题描述
正如本文所述 thread 以及 这里 我正在使用 mkbundle -o newfile oldfile.exe --static (OS: Ubuntu 11.10 64bit, Mono: 2.10.5) 创建一个可执行文件Apache Web 服务器(操作系统:Debian GNU/Linux 32 位).这里,oldfile.exe 是使用 mcs oldfile.cs 编译 C#-Hello-World-Code 的结果.在原始系统(使用 Ubuntu)上,该文件是可执行的.但是,当我在 Apache Web 服务器上调用 newfile 时,我会收到错误消息:
As mentioned in this thread as well as here I am using mkbundle -o newfile oldfile.exe --static (OS: Ubuntu 11.10 64bit, Mono: 2.10.5) to create a file which shall be executable on an Apache Web Server (OS: Debian GNU/Linux 32bit). Here, the oldfile.exe was the result of the compilation of a C#-Hello-World-Code using mcs oldfile.cs. On the original system (with Ubuntu) the file is executable. However, whenver I call newfile on the Apache Web Server I get the error:
无法执行二进制文件
另外,在执行 file newfile 时会说
Also, when doing file newfile it says
ELF 64 位 LSB 可执行文件,x86-64,版本 1 (SYSV),动态链接(使用共享库),未剥离
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
我怀疑如果 mkbundle 按预期工作,那么它应该已经读取
I suspect if mkbundle worked as it is supposed to, then it should have read
...静态链接...
不应该吗?任何人都知道为什么该文件在服务器上不可执行?是不是因为32bit/64bit的问题?
shouldn't it? Anyone an idea why the file is not executable on the Server? Is it a problem because of 32bit/64bit?
推荐答案
mkbundle from 64-bit Mono 生成 64-bit 可执行文件,您无法在 32-bit 内核上运行 64-bit 可执行文件.由于 mkbundle 没有生成 32 位二进制文件的选项,您显然需要使用 32 位 Mono 生成可执行文件(理论上您可以在 64 位系统上安装 32 位 Mono,但是不是很容易,所以我建议在某个地方安装一个 32 位系统,也许在 VM 中).
mkbundle from 64-bit Mono generates 64-bit executables and you cannot run a 64-bit executable on 32-bit kernel. As mkbundle doesn't have an option to generate 32-bit binaries you apparently need to generate your executable with 32-bit Mono (theoretically you can install 32-bit Mono on your 64-bit system but that is not very easy so I suggest installing a 32-bit system somewhere, maybe in VM).
这篇关于使用 mkbundle 从 C# 源代码创建 Linux 可执行文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 mkbundle 从 C# 源代码创建 Linux 可执行文件时出现问题
基础教程推荐
- 获取C#保存对话框的文件路径 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 将数据集转换为列表 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
