1 year ago

#324994

test-img

Andreas Spindler

Linking C++ Wayland application with g++ not possible?

I am trying to link a Wayland C++ application with g++ and got stuck. It should be possible to link to the Wayland libraries from C++ since the headers (wayland-core.h, wayland-client.h etc.) correctly put the API calls into an extern "C" scope.

I am using Ubuntu 20.04 LTS. Wayland is enabled and all libraries are installed:

 $ sudo apt-get update
 $ sudo apt-get install libwayland-client0 libwayland-dev libdrm-dev
 $ sudo apt-get install wayland-protocols

I can compile a simple program that connects to the wl_display singleton but linking is not possible:

 $ pkg-config --cflags --libs wayland-client
 -lwayland-client
 $ pkg-config --variable=libdir wayland-client
 /usr/lib/x86_64-linux-gnu
 $ g++ -std=c++17 -pthread -Wall -lwayland-client -L/usr/lib/x86_64-linux-gnu -o hello hello.cpp
 hello.cpp:(.text+0x1d): undefined reference to `wl_display_connect'
 /usr/bin/ld: hello.cpp:(.text+0x5c): undefined reference to `wl_display_disconnect'

There is another thread but they are linking a C program which works on my system too. Is it not possible to link C++ for some reason?

Thank you.

c++

linux

ubuntu

g++

wayland

0 Answers

Your Answer

Accepted video resources