-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Issue
After building and installing both cpr and influxdb-cxx i get the following error if I build and run the test_package example.
./test_package: error while loading shared libraries: libcpr.so.1: cannot open shared object file: No such file or directory
Even though the file exists and cpr works on its own.
Details
I've been struggling with this issue for a while and I don't understand why it occurs. I'm running a 64bit Ubuntu 22.04 LTS VM on a Windows host. I'm building and installing cpr as described in their repo with the flag CPR_USE_SYSTEM_CURL=ON.
I'm building this library with the flags INFLUXCXX_TESTING=OFF and INFLUXCXX_WITH_BOOST=OFF
I've tried with the latest master of both cpr and influxdb-cxx as well as cpr 1.10.0 together with influxdb-cxx v0.7.1 with the same outcome. If I try to build and run a similar minimalistic example using just cpr, that works fine which is why I believe that the issue isn't with cpr.
By coincidence I noticed that if I make an example that includes and uses cpr as well as influxdb-cxx it runs without the error, so something is not working when l just use influxdb-cxx in the project.
I might be missing something obvious, let me know if there's any more details needed.
For a minimal example that runs and doesn't give the error:
CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(test_package CXX)
find_package(InfluxDB REQUIRED)
find_package(cpr REQUIRED)
add_executable(test_package example.cpp)
target_link_libraries(test_package PRIVATE InfluxData::InfluxDB)
target_link_libraries(test_package PRIVATE cpr::cpr)
target_compile_features(test_package PRIVATE cxx_std_17)
example.cpp:
#include <InfluxDBFactory.h>
#include "cpr/cpr.h"
int main()
{
auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086?db=test");
influxdb->addGlobalTag("test", "value");
cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass", cpr::AuthMode::BASIC},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
}