0
我正在編寫一個C++程序來監視一個值並更改筆記本電腦上觸摸板和跟蹤點的啓用狀態。除了調用XIChangeProperty之外,我有一切工作。當我運行make時,拋出獲取對XIChangeProperty的未定義引用
undefined reference to `XIChangeProperty'
如果我從源中刪除#include <X11/extensions/XInput.h>
,它拋出一個不同的錯誤。
我cmake的文件如下
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)
我不知道我錯過了什麼,會導致XIChangeProperty顯示爲未定義。
GitHub的回購與代碼的其餘部分是在這裏https://github.com/kfechter/YogaModeSwitch