Using OBS Core API in C/C++

Birdo

New Member
Hello,

I am trying to make a program on Linux (Ubuntu 22.04 with Wayland) that uses the OBS Core API.
The program starts with a background and waits for some input that needs to be received.
When the data has been received, it shows that data over the background and this data can change every time.

I have created the scene and source correctly with OBS-Studio, that is working fine when I start it.

In my C/C++ program I want to implement the receiving part of the data and calling all the needed OBS function to create the same scene and source as I did in the OBS-Studio. The following problem occur:

When I only run the command:
C++:
obs_startup("en-US", nullptr, nullptr);
Code:
info: Unable to open X display
It runs the code but I get the problem that the X display can not be found.
This is correct because I am using Wayland.

Then I watched how the UI of the OBS-Studio solves this problem, because that runs correctly.
There is added the line:
C++:
obs_set_nix_platform(OBS_NIX_PLATFORM_WAYLAND);
Now my program is not looking for any X display but it knows that Wayland is set.
When I run the obs_startup afterwards I get a segmentation fault.
C++:
obs_startup("en-US", nullptr, nullptr);
Code:
info: Kernel Version: Linux 6.8.0-48-generic
info: Distribution: "Ubuntu" "22.04"
info: Desktop Environment: ubuntu:GNOME (ubuntu)
info: Session Type: wayland
Segmentation fault (core dumped)

With GDB I found that the segmentation fault happens at:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7acfe34 in wl_proxy_get_version () from /lib/x86_64-linux-gnu/libwayland-client.so.0

Can someone help me pointing the correct direction to solve this issue?

Kind regards
 

Tuna

Member
Use obs_set_nix_platform_display() to set your wayland display you want OBS to connect to before obs_startup().
 
Top