I may not be the first to ask about this; but I didn't find a solution yet. So maybe I'm not looking well.
I have compiled a small piece of code of 3 lines just to simulate a pressed key using xdo, with literally only one function call.
#include <cstdio>
#include <cstdlib>
#include <xdo.h>
#include <unistd.h>
int main() {
xdo_t * x = xdo_new(":0.0");
while(1) {
xdo_send_keysequence_window_down(x, CURRENTWINDOW, "KP_Space", 1);
}
return 0;
}
the cmake is looking like that:
cmake_minimum_required(VERSION 3.21)
project(remoteControl)
set(CMAKE_CXX_STANDARD 14)
include_directories(SYSTEM /usr/local/include)
link_libraries(/usr/local/lib/libxdo.so)
add_executable(remoteControl main.cpp)
I've tried with and without Cpp standard set. The execution give me:
[1] 55405 segmentation fault (core dumped) ./remoteControl
So first I've looked for missing link
$> ldd ./remoteControl
...
libxdo.so.3 => /usr/local/lib/libxdo.so.3 (0x00007fa110464000)
...
$> nm -u ./remoteControl
...
U xdo_new
U xdo_send_keysequence_window_down
So here we see that the xdo lib is well linked, bu there are missing symbols it, so I looked for these symbols over the libxdo.so file linked to the binary
$> nm -CgD /usr/local/lib/libxdo.so.3 | grep send
...
0000000000006390 T xdo_send_keysequence_window_down
...
So, the symbol is defined in the linked lib, but undefined in the output file. I'm not competent enough to understand what could be the problem, so if anyone can healp it would be great, thanks !
EDIT: the problem had nothing to do with linker... like @Some programer dude said in the comments, xdo_new
returns a null pointer on failure.