本文介绍了在Debian的C ++应用程序中使用GPGME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的C ++应用程序中使用GPGME来生成密钥和加密。但是,在尝试开始时,我遇到了一个问题:



我下载了dev包的debian系统。现在我想告诉我的编译器(gcc在Qt Creator)在哪里使用cmake找到库使用。但我不知道如何添加 gpgme-config --cflags --libs 到我的编译器标志。这不起作用:

  SET(CMAKE_CXX_FLAGS$ {CMAKE_CXX_FLAGS}`gpgme-config --cflags --libs` )

当我尝试构建应用程序时,编译器找不到 gpgme -config

  c ++:错误:$(gpgme-config:找不到文件或目录
c ++:错误:无法识别的命令行选项'--cflags'
c ++:错误:无法识别的命令行选项'--libs)'

无论如何执行 gpgme-config --cflags --libs 在命令行上给我一个结果:

  -L / usr / lib / x86_64-linux-gnu -lgpgme -lassuan -lgpg-error 

我知道文档还提到Automake和libtool,使这个过程更容易。但我之前都没有使用Automake或libtool。






UPDATE:
$ b

我也试图使用FindGpgme.cmake文件为GPGME。但我使用的几个其他cmake文件,我也下载了。我把它们放在与FindGpgme.cmake相同的目录中。找到了主要的cmake文件(FindGpgme.cmake),但是MacroEnsureVersion和MacroBoolTo01没有。我对我的CMakeLists.txt变化如下:

 包括:(cmake_modules / FindGpgme.cmake)
find_package(GPGME )

我在FindGpgme.cmake中尝试了其他文件的相对路径和绝对路径。同样的问题 - cmake找不到它们。我的第二个尝试是用的。错误是:



 在cmake_modules CMake的错误/ FindGpgme.cmake:376(set_package_properties):
未知的CMake命令 set_package_properties。
调用堆栈(最近调用的第一个):
CMakeLists.txt:7(include)


$ b b

我完全没有胶水如何解决 set_package_properties 问题。






UPDATE 2



我添加了

 code> include(FeatureSummary)

到我的CMakeLists.txt。现在我得到以下错误:

即使消息描述的接缝非常详细,我不知道如何FindGpgme.cmake添加到 CMAKE_MODULE_PATH 或如何请求添加前缀到 CMAKE_PREFIX_PATH 。 dev包是绝对安装的(使用包管理器)

解决方案

我建议使用一个正确的CMake查找脚本安装GPGME:



示例:



然后在你的CMake代码中进行类似的操作(未测试):

  find_package(GPGME)
include_directories($ {GPGME_INCLUDES})
target_link_libraries(YOURTARGET $ {GPGME_VANILLA_LIBRARIES)


I would like to use GPGME for key generation and encryption in my C++ application. However, while trying to get started, I got stuck with a problems:

I dowloaded the dev package for my debian system. Now I would like to tell my compiler (gcc in Qt Creator) where to find the library with cmake using the tool mentioned in the documentation. But I don't know how to add gpgme-config --cflags --libs to my compiler flags. This didn't work:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} `gpgme-config --cflags --libs` ")

When I try to build the app the compiler can't find gpgme-config:

c++: error: $(gpgme-config: File or Directory not found
c++: error: unrecognized command line option ‘--cflags’
c++: error: unrecognized command line option ‘--libs)’

Anyway executing gpgme-config --cflags --libs on command line DOES give me a result:

-L/usr/lib/x86_64-linux-gnu -lgpgme -lassuan -lgpg-error

I know the documentation also mentions Automake and libtool to make this process easier. But I neither used Automake or libtool before.


UPDATE:

I also tried to use a FindGpgme.cmake file for GPGME. But the first file I used required several other cmake files, which I also downloaded. I put them in the same directory as FindGpgme.cmake. The main cmake file (FindGpgme.cmake) was found, but MacroEnsureVersion and MacroBoolTo01 not. My change to my CMakeLists.txt was the following:

include(cmake_modules/FindGpgme.cmake)
find_package(Gpgme)

I tried relative and absolute path to the other files in FindGpgme.cmake. Same problem - cmake can't find them. My second try was with the file I found on gitweb. The error was:

CMake Error at cmake_modules/FindGpgme.cmake:376 (set_package_properties):
  Unknown CMake command "set_package_properties".
Call Stack (most recent call first):
  CMakeLists.txt:7 (include)

I have absolutely no glue how to fix that set_package_properties problem.


UPDATE 2

I added

include(FeatureSummary)

to my CMakeLists.txt as proposed by kfunk. Now I get the following error:

Even the message description seams pretty detailed I don't know how to add the FindGpgme.cmake to CMAKE_MODULE_PATH or how to add the requested prefix to CMAKE_PREFIX_PATH. The dev package however is definitely installed (using package manager)

解决方案

I'd suggest to use a proper CMake find script to look up the GPGME installation:

Example here: https://quickgit.kde.org/?p=kwallet.git&a=blob&h=7a092104ba0604b0606c4662750b8b32c5c3e2c6&f=cmake%2FFindGpgme.cmake&o=plain

Then something like this in your CMake code (untested):

find_package(Gpgme)
include_directories(${GPGME_INCLUDES})
target_link_libraries(YOURTARGET ${GPGME_VANILLA_LIBRARIES)

这篇关于在Debian的C ++应用程序中使用GPGME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 17:11