0
我的程序(如下)適用於Fedora 22,或者我直接從main()調用線程函數。但是如果我在Ubuntu 16.04的一個線程中啓動單聲道調用,它會這樣聲明。難道我做錯了什麼?Ubuntu的單線程崩潰
霍華德魯賓
輸出:
$ rm monotest.dll ; make ; ./monotest
Mono C# compiler version 4.8.0.0
mcs monotest.cs /out:monotest.dll /target:library
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
g++ monotest.cpp -o monotest -g3 -std=c++11 `pkg-config --cflags --libs mono-2`
* Assertion at mono-threads-posix.c:265, condition `info->handle' not met
Aborted (core dumped)
$
=============================== ===
// monotest.cpp
#include <thread>
#include <mono/jit/jit.h>
void Thread() {
MonoDomain* domain = mono_jit_init("monotest.dll");
mono_jit_cleanup(domain);
}
int main() {
//Thread();
std::thread t(Thread);
t.join();
}
==================================
////////////////////////
// monotest.cs
namespace MyNamespace {
public class MyClass {
public MyClass() { }
public void MySum(int arg1, int arg2) {
System.Console.WriteLine("MySum(" + arg1 + "," + arg2 + ") => " + (arg1 + arg2));
}
}
}
================= =================
###################
# Makefile
monotest : monotest.cpp monotest.dll Makefile
@g++ --version | head -1
g++ $< -o [email protected] -g3 -std=c++11 `pkg-config --cflags --libs mono-2`
monotest.dll : monotest.cs
@mcs --version
mcs $< /out:[email protected] /target:library