以DEB格式的Lunacy为例,安装后不能运行,报错

❯ ./Lunacy
./Lunacy: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./Lunacy)
./Lunacy: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./Lunacy)
./Lunacy: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./Lunacy)

解决办法是安装linuxbrew,然后使用linuxbrew安装需要的库

安装linuxbrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

设置清华镜像和环境变量,以zsh为例在~/.zshrc添加如下,bash则是~/.bashrc

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

修改Lunacy的依赖库

cd /opt/icons8/lunacy
sudo patchelf --set-interpreter /home/linuxbrew/.linuxbrew/lib/ld.so Lunacy
export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib:$LD_LIBRARY_PATH
./Lunacy

[!CAUTION] 注意export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib:$LD_LIBRARY_PATH不要添加到~/.zshrc~/.bashrc,因为这样会导致其他软件无法运行,只是临时设置

设置后启动仍然会报错

❯ ./Lunacy
Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'libICE.so.6' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
libICE.so.6: cannot open shared object file: No such file or directory
liblibICE.so.6: cannot open shared object file: No such file or directory
libICE.so.6.so: cannot open shared object file: No such file or directory
liblibICE.so.6.so: cannot open shared object file: No such file or directory
❯ ./Lunacy
Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'libSM.so.6' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
libSM.so.6: cannot open shared object file: No such file or directory
liblibSM.so.6: cannot open shared object file: No such file or directory
libSM.so.6.so: cannot open shared object file: No such file or directory
liblibSM.so.6.so: cannot open shared object file: No such file or directory

在linuxbrew里面安装需要的库

brew install libice
brew install libsm
brew install libxcursor
# 少什么库就安装什么就行

修改Desktop文件

[Desktop Entry]
Encoding=UTF-8
Version=9.6.2
Name=Lunacy
GenericName=Lunacy Graphic Editor
Exec=env LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib:$LD_LIBRARY_PATH /opt/icons8/lunacy/Lunacy %u
Icon=/opt/icons8/lunacy/Assets/LunacyLogo.png
Type=Application
Terminal=false
Categories=Graphics;Editors;
MimeType=x-scheme-handler/i8-lunacy;
StartupWMClass=Lunacy

Exec增加环境变量,就可以用快捷方式启动