C# monodevelop System.DllNotFoundException调用C+中的函数+;图书馆 我有一个C++库LIbMYLIb32.SO,用于Linux Ubuntu 32位。

C# monodevelop System.DllNotFoundException调用C+中的函数+;图书馆 我有一个C++库LIbMYLIb32.SO,用于Linux Ubuntu 32位。,c#,c++,linux,dll,monodevelop,C#,C++,Linux,Dll,Monodevelop,该库是在Ur/Pase/LIB中,我确认它是在C++程序中工作的。p> 在文件/etc/mono/config中我添加了 <dllmap dll="mylib32.dll" target="/usr/local/lib/libmylib32.so"/> 首先,我编写了一个类,其中声明了函数的接口: public class MyClass { [global::System.Runtime.InteropServices.DllImport("mylib32.dll", Entr

该库是在Ur/Pase/LIB中,我确认它是在C++程序中工作的。p> 在文件/etc/mono/config中我添加了

<dllmap dll="mylib32.dll" target="/usr/local/lib/libmylib32.so"/>
首先,我编写了一个类,其中声明了函数的接口:

public class MyClass
{

[global::System.Runtime.InteropServices.DllImport("mylib32.dll", EntryPoint="libhndl", CharSet = CharSet.Ansi)]
public static extern short libhndl( [MarshalAs(UnmanagedType.LPStr)] string ip, ushort port,int timeout, out ushort libHndl);

}
主程序调用函数libhndl:

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;


public class main_program
{
// ...
 ret = MyClass.libhndl(ip_address, tcp_port, tcp_timeout, out m_libHndl);
//...
}
如果我调试程序,调用函数时会出现异常:

System.DllNotFoundException: /usr/local/lib/libmylib32.so
 at (wrapper managed-to-native) MyClass:libhndl (string,uint16,int,uint16&)
 at main_program.function () [0x00056] in
 /home/f90100027/workspace/Ex_mono/Ex_mono/main_program.cs:306 
 at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
命令nm/usr/local/lib/libmylib32.so返回

...
000144c0 T libhndl
...
0013ee30 V _ZTV9SocketMgr 
         U _ZTVN10__cxxabiv117__class_type_infoE
...

我不完全知道MMOO如何使用C++代码,但我想你的问题与C++名字的修改有关。尝试将代码包装在
外部C
块中

试一试


相反。

1)设置env var
MONO\u LOG\u LEVEL=debug
以获得非常详细的转储信息,确切地说明MONO在哪里探测以找到共享库以及真正失败的地方。2) 跳过dllmap并使用LD_LIBRARY_PATH告诉Mono在哪里探测它,即“export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH这些应该获得更多信息来修复帮助您修复它,或者更多信息来帮助我们。我得到了一个我无法理解的未定义符号。MLO:DLIMLPORT错误加载库“LBYMYLB32”,“U/RR/PLATE/LIB/LBYMYLB32.SO:未定义的符号:ZZVN10YOCXXABIV117YA类,IOFEE”,看起来是C++名称管理,那些C++例程需要标记为<代码>外“C”< /代码>,我看到您的其他提交,您没有源码…您可以创建另一个基于C++的库,用<代码>外部“C”< /代码>包装这些调用。有关所需ABI调用接口的更多信息,请参阅。很遗憾,我没有库的源文件
System.DllNotFoundException: /usr/local/lib/libmylib32.so
 at (wrapper managed-to-native) MyClass:libhndl (string,uint16,int,uint16&)
 at main_program.function () [0x00056] in
 /home/f90100027/workspace/Ex_mono/Ex_mono/main_program.cs:306 
 at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
Mono: DllImport error loading library 'libmylib32.so': '/usr/local/lib/libmylib32.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE'. 
...
000144c0 T libhndl
...
0013ee30 V _ZTV9SocketMgr 
         U _ZTVN10__cxxabiv117__class_type_infoE
...
extern "C" {
short libhndl( const char *, unsigned short, long, unsigned short * );
}