【发布时间】:2018-07-17 14:33:28
【问题描述】:
这是我的 C++ 代码
#include "_app_switcher.h"
std::string c_meth(std::string str_arg) {
return "prpr";
}
我的单声道代码:
[Test]
public void TestDraft()
{
Console.WriteLine(c_meth("prpr"));
}
[DllImport("/home/roroco/Dropbox/cs/App.Switcher/c/app-switcher/lib/libapp-switcher-t.so")]
private static extern string c_meth(string strArg);
错误输出:
System.EntryPointNotFoundException : c_meth
at (wrapper managed-to-native) Test.Ro.EnvTest.c_meth(string)
at Test.Ro.EnvTest.TestDraft () [0x00001] in /home/roroco/Dropbox/cs/Ro/TestRo/EnvTest.cs:15
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <71d8ad678db34313b7f718a414dfcb25>:0
我猜是因为我的头文件不在/usr/include中,那么如何在mono中指定c++头文件?
【问题讨论】:
-
C++ 的
std::string和 .NET 的System.String不是同一类型。即使您修复了您现在看到的即时错误,这也不起作用。