0

I am writing a C++ program to monitor a value and change the enabled status of the touchpad and trackpoint on my laptop. I have everything working except for the call to XIChangeProperty. When I run make, it throws

 undefined reference to `XIChangeProperty'

If i remove the #include <X11/extensions/XInput.h> from the source, it throws a different error.

my cmake file is as follows

cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_INSTALL_PREFIX "/")
set(CPACK_PACKAGING_INSTALL_PREFIX "/")

project(thinkpad_yoga_mode_detection)

set (PROJECT_VERSION "1.0")
set (PACKAGE "${PROJECT_NAME}")
set (VERSION "${PROJECT_VERSION}")
set (PACKAGE_NAME "${PACKAGE}")
set (PACKAGE_TARNAME "${PACKAGE}")
set (PACKAGE_VERSION "${VERSION}")
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")

set(CMAKE_CXX_STANDARD 11)

find_package(X11 REQUIRED)
link_libraries(${X11_LIBRARIES})
include_directories(${X11_INCLUDE_DIR})

set(CMAKE_CXX_FLAGS "-O2")
set(CMAKE_CXX_FLAGS "-Wall")


set(SOURCE_FILES YogaModeSwitch.cpp)
add_executable(yoga_mode_switch ${SOURCE_FILES})
install(TARGETS yoga_mode_switch DESTINATION usr/bin)
install(
  FILES yoga_mode_switch_daemon DESTINATION etc/init.d
  PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
              GROUP_EXECUTE GROUP_READ
              WORLD_EXECUTE WORLD_READ)

I'm not sure what I am missing that would cause XIChangeProperty to show as undefined.

EDIT: The repo has been deleted (for now) removed link because it is dead

Fullmetal99012
  • 191
  • 3
  • 12

1 Answers1

1

It turns out I was missing a linker directive in the cmake file

once I added link_libraries(${X11_Xinput_LIB}) to the cmake file, cmake and make started working.

Fullmetal99012
  • 191
  • 3
  • 12