废话说完了,接下来正式进入开发流程,一般编程开发的第一步就是Hello World
。
本文主要测试Wayland的头文件、库能否正确链接。
依赖
先安装后续开发必要的依赖软件包
Ubuntu21.10
sudo apt install libwayland-dev libegl1-mesa-dev libglm-dev wayland-protocols libwayland-bin extra-cmake-modules
测试代码
#include <wayland-server.h>
#include <wayland-client.h>
#include <iostream>
using namespace std;
int main(){
cout<<"Hello world"<<endl;
}
编译方法
Qt
Meson
project('example_wayland', 'c', default_options : 'c_std=gnu11')
dependency('wayland-client')
c_flags = ['-g', '-Og']
ld_flags = ['-lwayland-client', '-lrt', '-lxkbcommon', '-lm']
src = ['src/main.c', 'src/xdg-shell-unstable-v6-client-protocol.c', 'src/int_set.c']
executable('example_wayland', src, c_args : c_flags, link_args : ld_flags)
CMake
Makefile
all:
g++ -o helloworld helloworld.cpp -lwayland-client -lwayland-server -lwayland-cursor -lwayland-egl
编译运行
hyper@ubuntu:~/Nutstore Files/Nutstore/Wayland$ make
g++ -o helloworld helloworld.cpp -lwayland-client -lwayland-server -lwayland-cursor -lwayland-egl
hyper@ubuntu:~/Nutstore Files/Nutstore/Wayland$ ./helloworld
Hello world
没有报错、没有异常,表示wayland相关头文件和库文件位置包含没有错。
完整代码在Wayland_Frashman下的6.hellow world
中。
本文首发于:Wayland入门6:hello world