Poco linking error when using Poco::NetSSL

161 views Asked by At

First of all, I am quite inexperienced when it comes to cmake, as I have only very recently started using it. I wanted to use POCO simply to send a message to a given email address. The code is uncomplicated and for all intents and purposes, can be seen as an equivalent to the code present in this example from the poco github. Afterwards, I tried to compile it using cmake, like I had previously done for the rest of my project. Checking online, it seems that adding

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

should make the cmake run. However, this leads to the following error

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)

I had also attempted to create a secondary empty project, for which I created a different CMakeLists.txt which contains only:

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)

Running cmake . works on this without issue, but adding Util and Poco::Util seems to always be problematic. I am not knowledgable enough to fix this issue. I have installed Poco as described on their website, and ran all cmake related commands on the site. I have also installed OpenSSL using apt-get install libssl-dev. I did not install the ODBC or SQL related dependencies cause they weren't needed, I only wanted to send emails.

Reverting the order of the packages in find_package seems to improve the situation:

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 . now successfully runs, but running make, the percentage never passes 0%, and running the resulting program gives the following error:

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

However, this file and all the other libs from Poco are located in the same directory, /usr/local/lib. Explicitly adding Crypto and Poco::Crypto in the find_package and target_link_libraries did not solve the issues.

Thank you for your time. Any suggestions are apreciated!

0

There are 0 answers