问题1:Hyprcursor的编译过程找不到tomlplusplus
因为想要编译Hyprland,它依赖Hyprcursor这个库,所以此库如果编译不成功会造成后面的安装都失败了
编译过程中会报FindPackage.cmake的相关错误,提示找不到tomlplusplus
深入调查发现,是它的Cmake文件里面,存在对pkg-config的使用,它用pkg-config去tomlplusplus
自然是很难找的
https://github.com/hyprwm/hyprcursor/blob/main/CMakeLists.txt
...
find_package(PkgConfig REQUIRED)
pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
hyprlang>=0.4.2
libzip
cairo
librsvg-2.0
tomlplusplus)
...
我也不想研究这么深了,想到一个简单粗暴的方法就是直接用apt命令安装,但是!
cody@SERVER-AT:~$ sudo apt install tomlplusplus-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
E: 无法定位软件包 tomlplusplus-dev
没办法,只能换个做法,由tomlplusplus
其实只有代码,没有静态/动态库,那就好办了下载它的源码,cmake
构建一个库,然后自己写一个pc文件来欺PkgConfig
工具。
#不多说,一行行执行,先把代码文件准备好
git clone https://github.com/marzer/tomlplusplus && cd tomlplusplus
sudo cmake -B build -DCMAKE_INSTALL_PREFIX=/opt/toml++
sudo cmake --install build
sudo cmake -B build -DCMAKE_PREFIX_PATH=/opt/toml++
sudo ln -sf /opt/toml++/include/toml++ /usr/include/toml++
接下来制造一个pc文件,touch tomlplusplus.pc
写这段内容:
prefix=/usr
includedir=${prefix}/include
Name: tomlplusplus
Description: Header-only TOML parser
Version: 3.4.0
Cflags: -I${includedir}
然后安装和验证
sudo install -m644 tomlplusplus.pc /usr/lib/pkgconfig/
pkg-config --cflags tomlplusplus # 应返回 -I/usr/include
# 验证是否能找到toml++ 出现版本号了就证明可以了
pkg-config --modversion tomlplusplus
3.4.0
再重新编译一次hyprcursor就没问题了
问题2:找不到各种库
-- Checking for modules 'xkbcommon;wayland-server;wayland-client;wayland-cursor;wayland-protocols;cairo;pango;pangocairo;pixman-1;libdrm;libinput;hwdata;libseat;libdisplay-info;libliftoff;libudev;gbm;hyprlang>=0.3.2;hyprcursor>=0.1.7'
-- No package 'hwdata' found
-- No package 'libdisplay-info' found
-- No package 'libliftoff' found
CMake Error at /usr/local/share/cmake-3.27/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
/usr/local/share/cmake-3.27/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
CMakeLists.txt:107 (pkg_check_modules)
直接手动下载和编译安装吧(适合所有发行版)
hwdata(仅数据文件,无代码,编译快)
git clone https://github.com/vcrhonek/hwdata
cd hwdata
sudo ./configure
sudo make install
libdisplay-info(EDID/DisplayID 解析)
git clone https://gitlab.freedesktop.org/emersion/libdisplay-info.git
cd libdisplay-info
meson setup build --prefix=/usr/local
sudo meson install -C build
libliftoff(Vulkan/DRM 合成辅助)
git clone https://gitlab.freedesktop.org/emersion/libliftoff.git
cd libliftoff
meson setup build --prefix=/usr/local
sudo meson install -C build
问题3:找不到xwayland
xwayland是一个wayland的中间件,用来兼容一些软件只能调X11
接口的桥接层
-- No package 'xwayland' found
CMake Error at /usr/local/share/cmake-3.27/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
/usr/local/share/cmake-3.27/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
CMakeLists.txt:183 (pkg_check_modules)
自动安装方案
sudo apt install xwayland
手动安装方案
先编译安装x协议
git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto.git
#也可以用下面这个镜像地址
#git clone https://gitee.com/openkylin/xorgproto.git
cd xorgproto
meson setup build --prefix=/usr/local
sudo meson install -C build
对于Linux Mint或者Ubuntu,先安装一些开发包
sudo apt update
sudo apt install -y wayland-protocols libwayland-dev libxcb1-dev libxcb-composite0-dev \
xkb-data xutils-dev libpciaccess-dev libxau-dev libxdmcp-dev libxkbfile-dev
git clone https://gitlab.freedesktop.org/xorg/xserver.git --depth=1
cd xserver
Xwayland 与完整 Xorg 在同一仓库,只需开启 -Dxwayland=true
即可:
meson setup build \
-Dprefix=/usr/local \
-Dxorg=false \
-Dxwayland=true \
-Dxvfb=false \
-Dxnest=false \
-Dglx=true \
-Ddrm=true \
-Ddri3=true \
-Dscreensaver=false
未完待续。。。