我安装了新的 ubuntu server 18.04,还运行了更新和升级。我确实按照本指南安装了最新的 mono https://www.mono-project.com/download/stable/#download-lin 并且我也选择了 mono-complete 以确保我获得了所有内容。
但是当我尝试编译基本的“Hello World”时出现错误。
Stacktrace:
/proc/self/maps:
40f6c000-40f7c000 rwxp 00000000 00:00 0
4198b000-419ab000 rwxp 00000000 00:00 0
5599439d0000-559943e19000 r-xp 00000000 fd:00 28394 /usr/bin/mono-sgen
559944018000-55994401f000 r--p 00448000 fd:00 28394 /usr/bin/mono-sgen
55994401f000-559944024000 rw-p 0044f000 fd:00 28394 /usr/bin/mono-sgen
559944024000-5599440b5000 rw-p 00000000 00:00 0
559944da8000-5599450dd000 rw-p 00000000 00:00 0 [heap]
7f335360c000-7f3353dc2000 r-xp 00000000 fd:00 28889 /usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so
7f3353dc2000-7f3353fc2000 ---p 007b6000 fd:00 28889 /usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so
7f3353fc2000-7f3353fc3000 r--p 007b6000 fd:00 28889 /usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so
7f3353fc3000-7f3353fc4000 rw-p 007b7000 fd:00 28889 /usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so
7f3353fc4000-7f3354000000 rw-p 00000000 00:00 0
7f3354000000-7f3354021000 rw-p 00000000 00:00 0
7f3354021000-7f3358000000 ---p 00000000 00:00 0
7f33584f1000-7f33584f3000 r--p 00000000 fd:00 80822 /usr/lib/mono/4.5/Facades/System.Globalization.dll
7f33584f3000-7f33584f5000 r--p 00000000 fd:00 80907 /usr/lib/mono/4.5/Facades/System.Text.Encoding.dll
7f33584f5000-7f33584f7000 r--p 00000000 fd:00 80891 /usr/lib/mono/4.5/Facades/System.Security.Cryptography.Primitives.dll
7f33584f7000-7f33584f9000 r--p 00000000 fd:00 80865 /usr/lib/mono/4.5/Facades/System.Resources.ResourceManager.dll
7f33584f9000-7f3358571000 rw-p 00000000 00:00 0
7f3358571000-7f33589e8000 r--p 00000000 fd:00 78322 /usr/lib/mono/4.5/Microsoft.CodeAnalysis.CSharp.dll
7f33589e8000-7f3358a06000 r--p 00000000 fd:00 28769 /usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll
7f3358a06000-7f3358d0e000 r--p 00000000 fd:00 28780 /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
7f3358d0e000-7f3358d30000 r--p 00000000 fd:00 77532 /usr/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
7f3358d30000-7f3358dbc000 r-xp 00000000 fd:00 28892 /usr/lib/mono/aot-cache/amd64/System.Collections.Immutable.dll.so
7f3358dbc000-7f3358fbb000 ---p 0008c000 fd:00 28892 /usr/lib/mono/aot-cache/amd64/System.Collections.Immutable.dll.so
Memory around native instruction pointer (0x7f3353b4d00e):
0x7f3353b4cffe 48 85 c9 0f 84 09 04 00 00 0f b6 89 88 00 00 00 H...............
0x7f3353b4d00e 66 0f 38 32 40 06 66 0f 38 00 05 c3 4b 27 00 44 [email protected]'.D
0x7f3353b4d01e 0f b6 40 05 49 c1 e0 28 0f b6 70 04 48 c1 e6 20 [email protected]..(..p.H..
0x7f3353b4d02e 0f b6 78 03 48 c1 e7 18 0f b6 58 02 48 c1 e3 10 ..x.H.....X.H...
Native stacktrace:
/usr/bin/mono(+0x129f8d) [0x559943af9f8d]
/usr/bin/mono(+0x12a295) [0x559943afa295]
/usr/bin/mono(+0xbfd2f) [0x559943a8fd2f]
/usr/bin/mono(+0x414e8) [0x559943a114e8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f3360e94890]
/usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so(+0x54100e) [0x7f3353b4d00e]
Pkilling 0x7f335a28f700 from 0x7f3361a63780
Entering thread summarizer pause from 0x7f3361a63780
Finished thread summarizer pause from 0x7f3361a63780.
Waiting for dumping threads to resume
Debug info from gdb:
mono_gdb_render_native_backtraces not supported on this platform, unable to find gdb or lldb
=================================================================
Got a SIGILL while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
我昨天确实运行了同样的东西,但是后来我确实使用了另一台计算机并且使用了 Xubuntu,所以它需要图形界面吗?
/UPDATE 当我尝试使用 Mono 的夜间版本时,“Hello World”脚本没有出现任何错误。
答案1
看起来你的记忆在这一行被破坏了:
Memory around native instruction pointer (0x7f3353b4d00e):
本机堆栈跟踪显示在此行引用相同的内存地址:
/usr/lib/mono/aot-cache/amd64/Microsoft.CodeAnalysis.CSharp.dll.so(+0x54100e) [0x7f3353b4d00e]
这意味着该库可能存在问题。我查看了目录,发现有问题的库实际上名为/usr/lib/mono/aot-cache/amd64/mscorlib.dll.so
。
执行时objdump -p /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so | grep NEEDED
没有列出我能看到的任何依赖项,因此我怀疑您的安装没有完全完成。
因此,在终端中测试一个简单的程序可以排除与单声道安装有关的任何问题。
请尝试以下操作:
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
创建上述文件并将其命名为 hello.cs 然后在终端执行以下操作:
mcs -out:hello.exe hello.cs
然后运行:
mono hello.exe
如果你的输出是:
Hello World!
Press any key to exit.
您知道这不是 mono 依赖项或安装的问题,而是您机器上其他二进制文件的问题。可能是因此libthread.so
要确保您拥有这些本地库...
由于您提到您正在使用 Ubuntu Server 版本(精简版),因此您可能需要引入任何 gcc/g++ 二进制文件。
sudo apt install build-essential