Search code examples
clinuxcmakexdotool

when use libxdo, it raise "error: unknown type name ‘useconds_t’"


here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_executable(ex ex.c)
target_link_libraries(ex xdo)

the full code is here

of course, the libxdo.so and xdo.h is exist


Solution

  • I find the reason, useconds_t in "unistd.h", but it require first use #define __USE_XOPEN, the right code is

    #include "unistd.h"
    #define __USE_XOPEN
    #include <xdo.h>