问题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
到了安装的后期,还有找不libinput
的,这个是因为当前系统的版本低了一档,哎~但是这个不妨碍继续安装,这是可能勾选input-group
脚本,导致的
Package 'libinput' has version '1.25.0', required version is '>= 1.26.0'
CMake Error at /usr/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
The following required packages were not found:
- libinput>=1.26.0
问题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
问题4:找不到hyprutils或者hyprlang
首先,正常执行安装脚本它会自动编译和安装一hyprutils
到你的系统环境,如果出现下面这个提示,就证明编译这个东西出错了
-- Package 'hyprutils', required by 'virtual:world', not found
CMake Error at /usr/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
The following required packages were not found:
- hyprutils>=0.7.1
🙈哎~真烦人,怎么连个print都找不到
/home/xxx/Debian-Hyprland/hyprutils/tests/memory.cpp:7:10: fatal error: print: 没有那个文件或目录
7 | #include <print>
| ^~~~~~~
先在终端输c++ --version
看看你的C++版本是不是大于或者等于14,如果不是的话,就要安装。
然cd
到hyprutils目录,告诉cmake新的编译器,并且尝试编译
cmake -B build -DCMAKE_CXX_COMPILER=g++-14
cmake --build build
如果上述操作没有问题,那就通过切换版本的方式把系统默认的C++编译器“替换”g++-14
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 101
然后重新执install.sh
脚本安装。
问题5:libinput版本低
有的时候会遇到
CMake Error at /usr/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
The following required packages were not found:
- libinput>=1.2.6
不多说,下载源码来升级吧
git clone https://gitlab.freedesktop.org/libinput/libinput.git
meson setup builddir \
--prefix=/usr/local
meson compile -C builddir
meson install -C builddir
#输提权密码
未完待续。。。