Avalonia使用CefNet 实现web-browsers(基于CentOS8 Arm64架构)

    • 前提

目标系统为CentOS8,CPU架构是arm64,因此CefGlue等都无法使用。参考https://github.com/AvaloniaCommunity/awesome-avalonia#web-browsers

    • 使用CefNet

参考https://github.com/CefNet/CefNet

    • 部署

1)执行报错System.DllNotFoundException

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
   at CefNet.NativeMethods.dlopen(String path, Int32 mode)
   at CefNet.CefNetApplication.Initialize(String path, CefSettings settings)

解决方式:参考https://github.com/CefNet/CefNet/issues/121

执行命令查找libdl.so,然后创建软连接libdl.so,此处你的安装目录是lib就 /usr/lib/libdl.so,是lib64就 /usr/lib64/libdl.so

[root@localhost ~]# locate libdl.so
/usr/lib64/libdl.so.2
# sudo ln -sf /usr/lib64/libdl.so.2 /usr/lib64/libdl.so

2)执行报错Can't load '/etc/opt/cef/Release/libcef.so',

解决方案:

1.添加环境变量,此方法需要每次开启程序之前都要执行一次

 export LD_PRELOAD=你的cef文件夹路径/Release/libcef.so:$LD_PRELOAD

例如:我的命令如下

 export LD_PRELOAD=/etc/opt/cef/Release/libcef.so:$LD_PRELOAD

2.修改 ~/.bashrc文件,在文件末尾添加export LD_PRELOAD=/etc/opt/cef/Release/libcef.so:$LD_PRELOAD,就不用每次都执行一遍命令了

 ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
export LD_PRELOAD=/etc/opt/cef/Release/libcef.so:$LD_PRELOAD
                                                                                 

3)执行报错Invalid file descriptor to ICU data received

解决方案:

将 cef/Resources/icudtl.dat 文件复制到cef/Release/ 目录下

4)如果是Avalonia项目,可能会报Default font family name can't be null or empty这个错误,错误信息如下:

Unhandled exception. System.InvalidOperationException: Default font family name can't be null or empty.
   at Avalonia.Media.FontManager..ctor(IFontManagerImpl platformImpl) in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 33
   at Avalonia.Media.FontManager.get_Current() in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 53
   at Avalonia.Media.TextFormatting.TextCharacters.TryGetRunProperties(ReadOnlySlice`1 text, Typeface typeface, Typeface defaultTypeface, Int32& count) in /_/src/Avalonia.Visuals/Media/TextFormatting/TextCharacters.cs:line 129
   at Avalonia.Media.TextFormatting.TextCharacters.CreateShapeableRun(ReadOnlySlice`1 text, TextRunProperties defaultProperties) in /_/src/Avalonia.Visuals/Media/TextFormatting/TextCharacters.cs:line 62

解决方案见:文章中的3.运行报错部分

你可能感兴趣的:(CentOS,Avalonia,centos,webview)