当前位置:   article > 正文

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

cefnet
    • 前提

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

    • 使用CefNet

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

    • 部署

1)执行报错System.DllNotFoundException
  1. 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
  2. at CefNet.NativeMethods.dlopen(String path, Int32 mode)
  3. 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

  1. [root@localhost ~]# locate libdl.so
  2. /usr/lib64/libdl.so.2
  3. # 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,就不用每次都执行一遍命令了

  1. ~/.bashrc
  2. # .bashrc
  3. # User specific aliases and functions
  4. alias rm='rm -i'
  5. alias cp='cp -i'
  6. alias mv='mv -i'
  7. # Source global definitions
  8. if [ -f /etc/bashrc ]; then
  9. . /etc/bashrc
  10. fi
  11. 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这个错误,错误信息如下:
  1. Unhandled exception. System.InvalidOperationException: Default font family name can't be null or empty.
  2. at Avalonia.Media.FontManager..ctor(IFontManagerImpl platformImpl) in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 33
  3. at Avalonia.Media.FontManager.get_Current() in /_/src/Avalonia.Visuals/Media/FontManager.cs:line 53
  4. 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
  5. at Avalonia.Media.TextFormatting.TextCharacters.CreateShapeableRun(ReadOnlySlice`1 text, TextRunProperties defaultProperties) in /_/src/Avalonia.Visuals/Media/TextFormatting/TextCharacters.cs:line 62

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/912443
推荐阅读
  

闽ICP备14008679号