我試圖使用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