Ubuntu22.04下CMake编译TigerVNC时无法检测到已安装的PAM开发文件
解决CMake编译TigerVNC时找不到PAM开发文件的问题
问题描述
在Ubuntu 22.04 LTS系统上使用CMake 3.22.1从源码编译TigerVNC 1.13.0,已满足绝大多数依赖项,但编译失败并报错**"Could not find PAM development files"**。已安装libpam0g-dev包,且确认目标PAM开发文件位于/usr/include/security/pam_appl.h,需要让CMake正确识别这些文件。
编译错误日志
Determining if files security/pam_appl.h exist failed with the following output: Change Dir: /usr/local/src/tigervnc/CMakeFiles/CMakeTmp Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_da0c0/fast && /usr/bin/gmake -f CMakeFiles/cmTC_da0c0.dir/build.make CMakeFiles/cmTC_da0c0.dir/build gmake[1]: Entering directory '/usr/local/src/tigervnc/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_da0c0.dir/HAVE_PAM_H.c.o /usr/bin/cc -std=gnu99 -Wall -Wextra -Wformat=2 -Wvla -o CMakeFiles/cmTC_da0c0.dir/HAVE_PAM_H.c.o -c /usr/local/src/tigervnc/CMakeFiles/CheckIncludeFiles/HAVE_PAM_H.c /usr/local/src/tigervnc/CMakeFiles/CheckIncludeFiles/HAVE_PAM_H.c:2:10: fatal error: security/pam_appl.h: No such file or directory 2 | #include <security/pam_appl.h> | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated. gmake[1]: *** [CMakeFiles/cmTC_da0c0.dir/build.make:78: CMakeFiles/cmTC_da0c0.dir/HAVE_PAM_H.c.o] Error 1 gmake[1]: Leaving directory '/usr/local/src/tigervnc/CMakeFiles/CMakeTmp' gmake: *** [Makefile:127: cmTC_da0c0/fast] Error 2 Source: /* */ #include <security/pam_appl.h> int main(void){return 0;} Determining if the function pam_start exists failed with the following output: Change Dir: /usr/local/src/tigervnc/CMakeFiles/CMakeTmp Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_4a751/fast && /usr/bin/gmake -f CMakeFiles/cmTC_4a751.dir/build.make CMakeFiles/cmTC_4a751.dir/build gmake[1]: Entering directory '/usr/local/src/tigervnc/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_4a751.dir/CheckFunctionExists.c.o /usr/bin/cc -std=gnu99 -Wall -Wextra -Wformat=2 -Wvla -DCHECK_FUNCTION_EXISTS=pam_start -o CMakeFiles/cmTC_4a751.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.22/Modules/CheckFunctionExists.c Linking C executable cmTC_4a751 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4a751.dir/link.txt --verbose=1 /usr/bin/cc -std=gnu99 -Wall -Wextra -Wformat=2 -Wvla -DCHECK_FUNCTION_EXISTS=pam_start CMakeFiles/cmTC_4a751.dir/CheckFunctionExists.c.o -o cmTC_4a751 -lpam /usr/bin/ld: cannot find -lpam: No such file or directory collect2: error: ld returned 1 exit status gmake[1]: *** [CMakeFiles/cmTC_4a751.dir/build.make:99: cmTC_4a751] Error 1 gmake[1]: Leaving directory '/usr/local/src/tigervnc/CMakeFiles/CMakeTmp' gmake: *** [Makefile:127: cmTC_4a751/fast] Error 2
解决方法
1. 手动指定PAM路径给CMake
执行CMake配置时,直接指定PAM的头文件目录和库路径:
cmake -DCMAKE_INCLUDE_PATH=/usr/include/security -DCMAKE_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu ..
CMAKE_INCLUDE_PATH:告诉CMake去哪里查找PAM头文件CMAKE_LIBRARY_PATH:指定PAM库文件(libpam.so)的所在路径,64位Ubuntu系统通常在/usr/lib/x86_64-linux-gnu
2. 直接指定PAM的具体路径参数
如果上述方法无效,可以强制指定PAM的头文件目录和库文件路径:
cmake -DPAM_INCLUDE_DIR=/usr/include/security -DPAM_LIBRARY=/usr/lib/x86_64-linux-gnu/libpam.so ..
3. 检查架构匹配性
确认系统架构与安装的libpam0g-dev版本匹配:
dpkg -L libpam0g-dev | grep libpam.so
输出应为/usr/lib/x86_64-linux-gnu/libpam.so(64位系统),如果是32位系统则路径为/usr/lib/i386-linux-gnu/libpam.so
4. 清理CMake缓存后重新配置
之前的CMake缓存可能导致识别错误,先清理再重新运行配置:
rm -rf CMakeFiles CMakeCache.txt # 然后执行上述任意一种CMake配置命令 cmake -DCMAKE_INCLUDE_PATH=/usr/include/security -DCMAKE_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu ..
内容的提问来源于stack exchange,提问作者Johnny B
相关产品推荐
相关产品推荐

