单本机二进制包无法加载新内核的libc [英] Mono native binary bundle fails to load libc in newer Linux kernels

查看:229
本文介绍了单本机二进制包无法加载新内核的libc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个C#单声道应用程序作为本机二进制,因此它可以在Linux系统上没有任何依赖关系(如单)上运行。

I'm attempting to build a C# Mono application as a native binary so it can be run on Linux systems without any dependencies (Such as Mono).

要确保我使用Ubuntu 12.04来构建本机二进制一些向后兼容性。我不得不从源代码编译单3.x作为Ubuntu的12.04只具有单声道2包我记录的这里这个过程中,如果你有兴趣

To ensure some backwards compatibility I am using Ubuntu 12.04 to build the native binary. I had to build Mono 3.x from source as Ubuntu 12.04 only has packages for Mono 2. I documented that process here, if you're interested.

我使用的 mkbundle 捆绑单声道运行及其相关性:

I am using mkbundle to bundle the Mono runtime and its dependencies:

mkbundle -c -o WFTOLauncherNative.c -oo bundles.o --static --deps WFTOLauncher.exe Open.NAT.dll

我使用cc编译像这样:

I am using the cc compiler like so:

cc -o WFTOLauncherNative.exe WFTOLauncherNative.c bundles.o -l:libmono-2.0.a -l:libgdiplus.a -lc -lpthread -lrt -lm -ldl -I /usr/local/include/mono-2.0/

这工作我建立它在系统上(Ubuntu的12.04)。不过在Ubuntu 14.04没有安装单我收到以下错误:

This works on the system I built it on (Ubuntu 12.04). However on Ubuntu 14.04 with no Mono installation I get the following error:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.DllNotFoundException: libc



LDD应用程序的:

ldd of the application:

scott@ubuntu:/media/strichnet/WFTOLauncher/bin/Release/LinuxNative$ ldd WFTOLauncherNative.exe
    linux-vdso.so.1 =>  (0x00007fffd0ffe000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa6c794a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa6c7d27000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa6c772c000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa6c7523000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa6c721d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa6c7019000)



我的预感至今是Mono是错在这里 - 我认为它依赖于单声道DllMap CONFIGS从libc中到libc.so.6的地图,但它的失败。关于被如此类似的问题和这里回答看起来很有希望,但我的目标是创建一个独立的本地组装的不是一个解决方案,我可以接受。

My hunch so far is Mono is at fault here - I think it relies on the Mono DllMap configs to map from libc to libc.so.6, but its failing. There is a similar question on SO and the answer here looks promising, but as my goal is to create an independent native assembly its not a solution I can accept.

我抄从/ etc /单声道/ config中的默认的单声道3的配置文件二进制目录,并将其重命名为WFTOLauncher.exe。配置和WFTOLauncherNative.exe.config(以防万一)。这并没有帮助

I have copied the default Mono 3 config file from /etc/mono/config to the binary directory and renamed it to WFTOLauncher.exe.config and WFTOLauncherNative.exe.config (Just in case). This has not helped.

完整的Mono调试跟踪在这里:的 https://gist.github.com/strich/e71b23421cdbe941b4f4

Full Mono debug trace here: https://gist.github.com/strich/e71b23421cdbe941b4f4

推荐答案

问题的根本原因是单音正在寻找libc.so那里的OS只有libc.so.6的。单需要DllMap配置文件,了解如何翻译这个。

The root cause of the problem was that Mono was looking for libc.so where the OS only had libc.so.6. Mono needs a DllMap config file to understand how to translate this.

该问题的解决方案是默认Mono3 DllMap配置文件添加到同一目录作为我的二进制文件。可悲的是,似乎单不缓存DllMap全球的过程,所以我不得不作出下,正在调用各种模块的不同名称的配置文件的多个重复副本。例如:

The solution to the problem was to add the default Mono3 DllMap config file to the same directory as my binary. Sadly it appears that Mono doesn't cache the DllMap globally for the process, so I had to make multiple duplicate copies of the config file under the different names of the various modules that were being called. For example:

Mono.Posix.dll.config
System.Drawing.dll.config
System.Windows.Forms.dll.config

这篇关于单本机二进制包无法加载新内核的libc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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