I am starting out with coding for Wayland. I have been following many tutorials, but I am still stuck at compiling. I wrote this very simple code:
#include<stdio.h>
#include<wayland-client-core.h>
int main(int argc, char *argv[]) {
struct wl_display *display = wl_display_connect(NULL);
if(!display) {
fprintf(stderr, "Failed to connect to Wayland display
");
return 1;
}
fprintf(stdout, "Connection established!
");
getchar();
wl_display_disconnect(display);
return 0;
}
Then, I tried to compile it with gcc -o client -lwayland-client client.c
But, compilation fails with this error message:
/usr/bin/ld: /tmp/ccfXeOS8.o: in function `main':
client.c:(.text+0x19): undefined reference to `wl_display_connect'
/usr/bin/ld: client.c:(.text+0x7c): undefined reference to `wl_display_disconnect'
collect2: error: ld returned 1 exit status
This looks strange because there is a file /usr/include/wayland-client-core.h
in the system, which has got these declarations:
struct wl_display *wl_display_connect(const char *name);
void wl_display_disconnect(struct wl_display *display);
What am I doing wrong here?
question from:
https://stackoverflow.com/questions/65919172/how-to-link-wayland-header-files-in-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…