小编Dav*_*agl的帖子

使用 libpam0g-dev 和 cmake 构建应用程序

我正在尝试构建一个使用库 libpamg0-dev 的 C++ 应用程序。我在我的elementaryOS VM 上使用以下命令安装了它。

apt-get install libpam0g-dev
Run Code Online (Sandbox Code Playgroud)

当我尝试编译应用程序时,编译器会吐出以下错误:

undefined reference to `pam_start`
undefined reference to `pam_authenticate`
undefined reference to `pam_end`
Run Code Online (Sandbox Code Playgroud)

我的 CMakeLists.txt 看起来像这样:

cmake_minimum_required(VERSION 3.10)
project(application)

set(CMAKE_CXX_STANDARD 11)

INCLUDE_DIRECTORIES(/home/dnagl/dev/libs/restbed/distribution/include /usr/include/security)
LINK_DIRECTORIES(/home/dnagl/dev/libs/restbed/distribution/library /usr/lib/x86_64-linux-gnu)

add_executable(application main.cpp Utils/Json/Json.cpp Utils/Json/Json.h Utils/Stringhelper/Stringhelper.cpp Utils/Stringhelper/Stringhelper.h Utils/File/Filehelper.cpp Utils/File/Filehelper.h Utils/System/SystemHelper.cpp Utils/System/SystemHelper.h  Controller/Info/InfoController.cpp Controller/Info/InfoController.h Rest/ResourceHandler/ResourceHandler.cpp Rest/ResourceHandler/ResourceHandler.h Controller/System/SystemController.cpp Controller/System/SystemController.h Rest/Log/RequestLogger.cpp Rest/Log/RequestLogger.h Controller/Authentication/AuthenticationController.cpp Controller/Authentication/AuthenticationController.h Controller/Log/LogController.cpp Controller/Log/LogController.h)

target_link_libraries(application restbed)
Run Code Online (Sandbox Code Playgroud)

也许你们中的一个人知道如何以正确的方式链接库。

c++ linux build cmake pam

4
推荐指数
1
解决办法
468
查看次数

标签 统计

build ×1

c++ ×1

cmake ×1

linux ×1

pam ×1