我试图使用mono加载一些本机linux库。 我已经跑单与调试标志:在Linux上使用Mono进行本地P /调用:DllNotFound
Mono: DllImport attempting to load: 'libavformat.57'.
Mono: DllImport error loading library '/home/filoe/Desktop/cscore/cscore/Samples/LinuxSample/bin/Debug/libavformat.57': '/home/filoe/Desktop/cscore/cscore/Samples/LinuxSample/bin/Debug/libavformat.57: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/home/filoe/Desktop/cscore/cscore/Samples/LinuxSample/bin/Debug/libavformat.57.so': 'libavcodec.so.57: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/lib/libavformat.57': '/usr/lib/libavformat.57: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/lib/libavformat.57.so': '/usr/lib/libavformat.57.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libavformat.57': 'libavformat.57: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libavformat.57.so': 'libavformat.57.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libavformat.57': 'libavformat.57: cannot open shared object file: No such file or directory'.
Mono: DllImport unable to load library 'libavformat.57: cannot open shared object file: No such file or directory'.
Mono: DllImport attempting to load: 'libavformat.57'.
有很多查找位置,但它们中的至少一个应该匹配。 这是我的目录看起来像:
[email protected]:~/Desktop/cscore/cscore/Samples/LinuxSample/bin/Debug$ dir
CSCore.Ffmpeg.dll CSCore.Ffmpeg.dll.mdb CSCore.Linux.dll.config FFmpeg libavformat.57 libswresample.2 LinuxSample.exe.mdb
CSCore.Ffmpeg.dll.config CSCore.Linux.dll CSCore.Linux.dll.mdb libavcodec.57 libavutil.55 LinuxSample.exe log.txt
[email protected]:~/Desktop/cscore/cscore/Samples/LinuxSample/bin/Debug$
正如你所看到的,libavformat.57
是存在的。 那么,单声道告诉我,它无法找到?
下面的代码演示怎样做:
的一些DllImport
方法声明:
[DllImport("avformat-57", EntryPoint = "av_register_all", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern void av_register_all();
[DllImport("avcodec-57", EntryPoint = "avcodec_register_all", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern void avcodec_register_all();
该项目还包含一个名称为文件“{输出程序集的名称}的.config “:
<configuration>
<dllmap os="linux" dll="avcodec-57" target="libavcodec.57"/>
<dllmap os="linux" dll="avformat-57" target="libavformat.57"/>
</configuration>
正如你在上面看到的,映射工作正常。 单声道需要“avformat-57”并将其转换为“libavformat.57”。 现在单声道搜索名为“libavformat.57”或类似“libavformat.57.so”的相关名称的库。 在执行程序集的目录中进行单声道搜索。
但是,它无法找到它正在寻找的文件(根据上面公布的日志)。所以为什么?
谢谢!
问候
共享库有一个'.so'扩展,这是不正确拿起库,尝试重命名,并重新创建参考共享库? – t0mm13b
不,它不会汇集我正在使用的扩展名或文件名的组合。错误信息是一个肯定存在的文件,不能被mono找到。 –
告诉我们一个[MCVE]来证明这一点。 – t0mm13b