You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GTK编译configure脚本XInput2检测失败及参数无效求助

GTK configure检测XInput2失败的排查与修改建议

问题描述

执行GTK的configure脚本时,触发XInput2检测错误:

configure: error: *** XInput2 extension not found. Check 'config.log' for more details.

查看config.log后,发现核心错误内容与上述提示一致,仅多了行号信息。

检测逻辑分析

从configure.ac中提取的完整XInput检测代码如下:

if $PKG_CONFIG --exists "xi" ; then

X_PACKAGES="$X_PACKAGES xi"
GTK_PACKAGES_FOR_X="$GTK_PACKAGES_FOR_X xi"

AC_CHECK_HEADER(X11/extensions/XInput2.h,
                have_xinput2=yes
                AC_DEFINE(XINPUT_2, 1, [Define to 1 if XInput 2.0 is available]))

gtk_save_LIBS="$LIBS"
LIBS="$LIBS -lXi"

# Note that we also check that the XIScrollClassInfo struct is defined,
# because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(), but not the XIScrollClassInfo struct.
AC_CHECK_FUNC([XIAllowTouchEvents],
  [AC_CHECK_MEMBER([XIScrollClassInfo.number],
                   have_xinput2_2=yes
                   AC_DEFINE(XINPUT_2_2, 1, [Define to 1 if XInput 2.2 is available]),
                   have_xinput2_2=no,
                   [[#include <X11/extensions/XInput2.h>]])])
LIBS="$gtk_save_LIBS"

if test "x$have_xinput2_2" = "xyes"; then
  X_EXTENSIONS="$X_EXTENSIONS XI2.2"
else
  X_EXTENSIONS="$X_EXTENSIONS XI2"
 fi
fi

AS_IF([test "x$have_xinput2" != "xyes"],
    [AC_MSG_ERROR([*** XInput2 extension not found. Check 'config.log' for more details.])])

已尝试的无效参数

尝试传递以下参数,但未通过检测:

  • PKG_CONFIG_PATH=:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/lib/pkgconfig/:预期满足$PKG_CONFIG --exists "xi"检测
  • CPPFLAGS=-I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/include/:预期通过AC_CHECK_HEADER(X11/extensions/XInput2.h)检测

另外,传递--disable-xinput参数后,检测仍未被禁用。


排查步骤

  1. 手动验证pkg-config检测
    执行以下命令确认pkg-config能否找到xi包:

    PKG_CONFIG_PATH=:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/lib/pkgconfig/ pkg-config --exists "xi" && echo "found" || echo "not found"
    

    若输出not found,检查目标目录下是否存在xi.pc文件,且文件内的路径配置正确。

  2. 验证头文件可用性
    执行以下命令测试头文件能否被正确识别:

    cpp -E -I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/include/ - <<EOF
    #include <X11/extensions/XInput2.h>
    EOF
    

    若报错,确认目标include目录下是否存在X11/extensions/XInput2.h文件。

  3. 检查Xi版本兼容性
    代码中除了检测头文件,还验证了XIAllowTouchEvents函数和XIScrollClassInfo.number成员。Xi 1.5.0版本可能不支持XI2.2的相关特性,但只要have_xinput2被设为yes就应通过基础检测。需仔细查看config.log中AC_CHECK_HEADER的具体测试输出,确认头文件检测是否真的通过。

修改检测逻辑的建议

临时跳过检测

直接修改configure.ac,将强制报错的逻辑注释或修改:

# 注释掉原错误触发代码
# AS_IF([test "x$have_xinput2" != "xyes"],
#     [AC_MSG_ERROR([*** XInput2 extension not found. Check 'config.log' for more details.])])

或在检测块内强制设置have_xinput2=yes:

if $PKG_CONFIG --exists "xi" ; then
  have_xinput2=yes  # 新增此行
  X_PACKAGES="$X_PACKAGES xi"
  # 后续原有代码...
fi

修复--disable-xinput参数无效问题

GTK的--disable-xinput可能仅针对旧版XI1,需手动添加XI2的禁用逻辑:

  1. 在configure.ac开头添加参数定义:
    AC_ARG_ENABLE([xinput],
                  [AS_HELP_STRING([--disable-xinput], [Disable XInput support])],
                  [enable_xinput=$enableval],
                  [enable_xinput=yes])
    
  2. 将原有Xi检测代码包裹在启用判断内:
    if test "x$enable_xinput" = "xyes"; then
      # 原有Xi检测代码块
      if $PKG_CONFIG --exists "xi" ; then
        ...
      fi
    else
      have_xinput2=yes  # 跳过检测时直接设为通过
    fi
    

修改完成后,重新执行autoreconf -i生成新的configure脚本。

内容的提问来源于stack exchange,提问作者user2752471

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 02:10:18