0

I have a piece of code that accesses data using cURL and prints it as a string. This part is working fine. I need to take this string and parse it using Jsoncpp. However, when I add the line:

Json::Value json_data;

there is a runtime error:

libjsoncpp.so.20: cannot open shared object file: No such file or directory

My CMakeLists.txt is given below (The commented out lines are things that I tried):

cmake_minimum_required(VERSION 3.5.1)
project(imu_data_access_class)
set(CMAKE_CXX_STANDARD 11)
find_package(CURL REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)
#link_libraries(${JSONCPP_LIBRARIES})
#set(INCLUDE_DIRS ${JSONCPP_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
#set(INCLUDE_DIRS /usr/local/include ${CURL_INCLUDE_DIRS})
#include_directories(${INCLUDE_DIRS})
set(SOURCES imu_data_access_class.cpp ${CURL_INCLUDE_DIRS}/curl/curl.h)
add_executable(imu_data_access_class ${SOURCES})
#target_include_directories(imu_data_access_class PUBLIC ${Jsoncpp_INCLUDE_DIRS})
set(LIBS ${JSONCPP_LIBRARIES} ${CURL_LIBRARIES})
target_link_libraries(imu_data_access_class ${LIBS})

Kindly help fix this error.

Edit 1: cmake output:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CURL: /usr/lib/aarch64-linux-gnu/libcurl.so (found version "7.47.0") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'jsoncpp'
--   Found jsoncpp, version 1.8.4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nvidia/ws/imu_data_access_class
skr
  • 914
  • 3
  • 18
  • 35
  • what is your cmake output? – aram Mar 06 '18 at 16:33
  • 3
    Have you installed `libjsoncpp` on your system? On Debian or Ubuntu you need to `sudo apt-get install libjsoncpp-dev` – Basile Starynkevitch Mar 06 '18 at 16:34
  • @Aram: cmake output added. – skr Mar 06 '18 at 16:35
  • @BasileStarynkevitch: I am using Ubuntu and I can see `libjsoncpp.so.20` when I do a file search. However, I am doing the installation again using the command in your comment. – skr Mar 06 '18 at 16:36
  • 1
    Run `ldd` on the executable obtained by your compilation. Perhaps also do a `ldconfig` – Basile Starynkevitch Mar 06 '18 at 16:41
  • @BasileStarynkevitch The installation worked. Thank You. I was not aware that this file was to be installed separately. I was under the impression that it was an error in my `CMakeLists.txt`, since I could see a file by this name already available in my system. – skr Mar 06 '18 at 16:47

0 Answers0