本机P/与Mono在Linux上使用Mono:dllnotfound



我正在尝试使用单声道加载一些本机Linux库。我已经带有调试标志的单声道:

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'.

有很多查找位置,但其中至少一个应该匹配。这就是我的目录的样子:

filoe@ubuntu:~/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
filoe@ubuntu:~/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>

如上所述,映射正常。Mono采用" Avformat-57",并将其翻译成" Libavformat.57"。现在,单声道搜索带有名称" libavformat.57"或一些相关名称的库,例如" libavformat.57.so"。执行程序集的目录中的单声道搜索。

但是,它无法设法找到它正在寻找的文件(根据上面发布的日志)。那为什么?

谢谢!

问候

关键是使用命令

ldd libavformat.57

具有以下输出:

linux-vdso.so.1 =>  (0x00007ffdf9bd6000)
libavcodec.so.57 => not found
libavutil.so.55 => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4a74652000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4a74439000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4a7421b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4a73e56000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4a74d73000)

因此,我将其重命名为建议的名称,并再次尝试并没有成功。下一个尝试

LD_LIBRARY_PATH=./ ldd libavformat.so.57

成功。我已经调整了配置文件,现在我可以使用

启动该应用程序
LD_LIBRARY_PATH=./ mono MyApp.exe

最新更新