使用 Poco::NetSSL 时出现 Poco 链接错误

问题描述 投票:0回答:1

首先,我对cmake还很缺乏经验,因为我最近才开始使用它。我想简单地使用 POCO 向给定的电子邮件地址发送消息。该代码并不复杂,并且出于所有意图和目的,可以将其视为与 poco github 中的example中的代码等效。之后,我尝试使用 cmake 编译它,就像我之前为项目的其余部分所做的那样。网上查了一下,好像是加了

find_package(Poco REQUIRED COMPONENTS Foundation NetSSL Util XML)
target_link_libraries(PROJECT_NAME PUBLIC Poco::Foundation Poco::NetSSL Poco::Util Poco::XML)

应该使 cmake 运行。 但是,这会导致以下错误

CMake Error at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    /usr/local/lib/cmake/Poco/PocoUtilConfig.cmake

  but it set PocoUtil_FOUND to FALSE so package "PocoUtil" is considered to
  be NOT FOUND.  Reason given by package:

  The following imported targets are referenced, but are missing: Poco::XML
  Poco::JSON

Call Stack (most recent call first):
  /usr/local/lib/cmake/Poco/PocoNetSSLConfig.cmake:3 (find_dependency)
  /usr/local/lib/cmake/Poco/PocoConfig.cmake:29 (find_package)
  CMakeLists.txt:8 (find_package)

我还尝试创建一个辅助空项目,为此我创建了一个不同的 CMakeLists.txt,其中仅包含:

cmake_minimum_required(VERSION 3.22)
project(main)
add_executable(main main.cpp)
find_package(Poco REQUIRED Foundation XML JSON)
target_link_libraries(main PUBLIC Poco::Foundation Poco::XML Poco::JSON)

运行

cmake .
可以毫无问题地解决此问题,但添加 Util 和 Poco::Util 似乎总是有问题。 我的知识不足以解决这个问题。 我已经按照 Poco 网站上的说明安装了 Poco,并在该网站上运行了所有与 cmake 相关的命令。我还使用
apt-get install libssl-dev
安装了 OpenSSL。 我没有安装 ODBC 或 SQL 相关依赖项,因为不需要它们,我只想发送电子邮件。

恢复

find_package
中的包裹顺序似乎可以改善情况:

find_package(Poco REQUIRED Foundation XML JSON Util NetSSL)
target_link_libraries(
    PROJECT_NAME PUBLIC Poco::Foundation Poco::JSON Poco::XML Poco::Util Poco::NetSSL
)

cmake 。现在成功运行,但是运行 make,百分比永远不会超过 0%,并且运行生成的程序会出现以下错误:

./PROGRAM_NAME: error while loading libPocoCrypto.so.95: cannot open shared object file: No such file or directory

但是,该文件和 Poco 中的所有其他库位于同一目录 /usr/local/lib 中。 在 find_package 和 target_link_libraries 中显式添加 Crypto 和 Poco::Crypto 并没有解决问题。

感谢您的宝贵时间。任何建议表示赞赏!

cmake poco-libraries
1个回答
0
投票

我在cmake方面更加缺乏经验,所以,不幸的是,我无法帮助你解决你的问题,但我希望其他人可以:))

© www.soinside.com 2019 - 2024. All rights reserved.