jpbarrette/curlpp

Clion build project

kulichkoff opened this issue · 1 comments

What is the problem

cmake links your library (curlpp) with absolute path. The result of ldd ./my-binary.

image

I have created the issue here 'cause the another library is included well.

What behavior did I expect

cmake links curlpp library from /usr/lib/... path or includes it right in binary file (which is preferable for my current purpose).

About my project structure

I have a directory to store libraries right in project. Where curlpp is stored too. You could get my project repo from https://github.com/kulichkoff/currencier.

There is my root CMakeLists.txt

cmake_minimum_required(VERSION 3.23)
project(currencier)

set(CMAKE_CXX_STANDARD 20)

add_subdirectory(libs/curlpp-0.8.1)
add_subdirectory(libs/json-3.11.2)

add_executable(currencier main.cpp src/http_client.cc src/http_client.h src/currency_parser.cc src/currency_parser.h)

target_link_libraries(currencier PUBLIC curlpp nlohmann_json)

target_include_directories(currencier PUBLIC
        libs/curlpp-0.8.1/include
        libs/json-3.11.2/include
        )

I don't know how to solve the problem. I am new in C++ and cmake. I hope for help. Sorry for my grammar.

Solved my problem

I was looking through your CMakeLists.txt and got the option to link the library statically

Added curlpp_static instead of curlpp:

target_link_libraries(currencier PUBLIC curlpp_static nlohmann_json)

But I still have a question

What if I want to link the library as a external dependecy (or dynamically)?