How to link Linux libraries like udev?

I’m writing some C++ code that uses udev library available on Ubuntu 16.04. If I was writing standalone executable I can link my code by ether specifying -ludev option to GCC or using following line in CMakeLists.txt:

target_link_libraries(MyExecutable udev)

How do I do this in Unreal build system? The problem is that I can’t use PublicAdditionalLibraries in Build.cs because the file name for Linux libraries like udev could be libudev.1.so or something like that which is system dependent wich why GCC option -ludev exists.

Background info: The reason I’m using udev is to get joystick vendor ID which seems to be the only viable way in Linux. The reason I’m getting in to this at all is because Unreal doesn’t support DirectInput based joysticks like flight RCs :(.

Hi,

You should be able to use PublicAdditionalLibraries.Add(“udev”) as this will pass -ludev to the linker in the UBT toolchain. This is how Core.Build.cs links in dlopen for example.

Also as a note to your reasoning for using udev directly; UE4 uses SDL for the input backend (which uses udev and evdev internally) and therefore it should be able to be updated to support your joystick without needing to use udev in the engine code. There are essentially two ways you can do this:

  1. Map the joystick to an xinput (XBox) style controller using the SDL GameController mappings.
  2. One way is mapping the joystick can be done is through the functions SDL_GameControllerMapping - SDL Wiki
  3. Another way is passing in the mappings as an environment variable SDL_GAMECONTROLLERCONFIG.
  4. Finally you can also find a community crowd source database of input mappings here GitHub - gabomdq/SDL_GameControllerDB: A community sourced database of game controller mappings to be used with SDL2 Game Controller functionality and then (as directed in the readme) use SDL_GameControllerAddMappingsFromFile.
  5. Add in your own SDL_Joystick code into LinuxApplication.cpp and use this code path if SDL_IsGameController returns false.