cmake vcpkg on Linux : undefined reference to SDL_IBus_Init

Hi!

I received these messages when configuring my project with CMake:

CMake Warning at ./vcpkg/registries/git-trees/.../portfile.cmake:34 (message):
  You will need to install Xorg dependencies to use feature x11:

  sudo apt install libx11-dev libxft-dev libxext-dev

Call Stack (most recent call first):
  scripts/ports.cmake:206 (include)


CMake Warning at ./vcpkg/registries/git-trees/.../portfile.cmake:37 (message):
  You will need to install Wayland dependencies to use feature wayland:

  sudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev

Call Stack (most recent call first):
  scripts/ports.cmake:206 (include)


CMake Warning at ./vcpkg/registries/git-trees/.../portfile.cmake::40 (message):
  You will need to install ibus dependencies to use feature ibus:

  sudo apt install libibus-1.0-dev

Call Stack (most recent call first):
  scripts/ports.cmake:206 (include)

Completed submission of sdl3[core,ibus,wayland,x11]:x64-linux@3.4.2#1 to 1 binary cache(s) in 1.5 s (1/1)
All requested installations completed successfully in: 1.5 min

And when building my project (I just copied the code from the official documentation) I receive these errors during the linking phase :

: && /usr/bin/c++ -g -pthread -Wl,--dependency-file=CMakeFiles/run.dir/link.d CMakeFiles/run.dir/src/main.cpp.o -o Debug/run  vcpkg_installed/x64-linux/debug/lib/libSDL3.a  -lm && :
/usr/bin/ld: vcpkg_installed/x64-linux/debug/lib/libSDL3.a(SDL_ime.c.o): in function `InitIME':
./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:75:(.text+0x25): undefined reference to `SDL_IBus_Init'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:76:(.text+0x33): undefined reference to `SDL_IBus_Quit'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:77:(.text+0x41): undefined reference to `SDL_IBus_SetFocus'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src//core/linux/SDL_ime.c:78:(.text+0x4f): undefined reference to `SDL_IBus_Reset'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:79:(.text+0x5d): undefined reference to `SDL_IBus_ProcessKeyEvent'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:80:(.text+0x6b): undefined reference to `SDL_IBus_UpdateTextInputArea'
/usr/bin/ld: ./vcpkg/buildtrees/sdl3/.../src/core/linux/SDL_ime.c:81:(.text+0x79): undefined reference to `SDL_IBus_PumpEvents'

I suspect that to correct these errors I would just have to install the mentioned dependencies and restart everything but I still have doubts; especially about this “ibus”. I see that in the vcpkg port it is defined as part of the “default-features”. Does that mean “mandatory” ?

Thank you :slight_smile:

First and foremost thanks for having accepted my question. It has taken time, but at least here we are :grinning_face:

Someone have recently opened an issue that is similar to the one I have encountered here [sdl3] build error on x64-linux-dynamic #50904".

I have tried to disable the “ibus” feature with the command vcpkg add port sdl3[wayland,x11] but it didn’t worked. The guy who have opened the issue say that he have managed to disable it but I’m not sure how he did :

I managed to disable it, when just using SDL3, however with ImGui’s sdl-binding it gets pulled in with default-features again.

Here’s a repository with the setup that I use : SDL_VCPKG_SETUP, I would have liked to provide a Docker image, but I haven’t had time to work on it yet.

For now, I install SDL with a git submodule and it works, so I think the problem comes from the vcpkg’s SDL port.

I was able to compile the example you linked by writing gcc example.c -g -lSDL3

I don’t know if that’s a difference in my distro, or if it’s because I’m not trying to compile with a build system. I never got around to trying to compile with cmake (except that one time I was building sdl3 from source). If your project is one file there’s nothing wrong with skipping a build system. I don’t use a build system for any of my projects (unless my own custom build system counts)

Thanks for your reply. I’m not sure how you did it, because

  1. there’s no example.c file (I mean in the src folder)
  2. did you use vcpkg to install SDL?

If your project is one file there’s nothing wrong with skipping a build system.

This is a minimal project intended for testing a configuration; my “real” project contains dozens of files.

I simply copied paste the example you linked into a c file. I installed SDL3 through my distro package manager (apt or pacman depending on the machine). IIRC SDL was extremely easy to build, maybe you’d have better luck by building it. I never shipped a program linking to the SDL I built so idr if there are any difficulties running on other peoples machines. I usually ship something built from a container or vm, linking only to what distros provide