Michel Feinstein
Michel Feinstein

Reputation: 14276

How to include curl.h in CLion?

I am programming a Raspberry Pi as a Remote Linux Host in my PC with CLion. In order to include curl I executed:

apt-get install libcurl4-openssl-dev

Then included in my C++ file:

#include <curl/curl.h>

And in CMakeList.txt:

cmake_minimum_required(VERSION 3.10.2)
project(Central)

set(CMAKE_CXX_STANDARD 17)

add_executable(Central main.cpp services/MyService.cpp services/MyService.h model/MyModel.cpp model/MyModel.h)

set(EXECUTABLE_OUTPUT_PATH "bin")

find_package (CURL)
if (CURL_FOUND)
    include_directories(${CURL_INCLUDE_DIRS})
    target_link_libraries(Central ${CURL_LIBRARIES})
else()
    MESSAGE(FATAL_ERROR "LibCurl is not found in your system.")
endif (CURL_FOUND)

target_link_libraries(Central ${LIBS})

Honestly, I am COMPLETELY new to CMake and this code I copied from a blog post, I have no idea on how much I need it or if anything is missing there.

Then I copied and pasted an example from the curl website.

The code executes fine but all the curl definitions are marked as erros in CLion:

CUrl error

So I can't get autocomplete from curl.

The #include <curl/curl.h> gives me this error:

curl not found

But again, the code executes fine, and other libraries inside the Raspberry Pi don't give me this error.

I can find the library at usr/include/arm-linux-gnueabihf/curl/curl.h inside the Raspberry Pi, but including this path gives me the same error.

Someone could explain me what's going on and how can I fix it?

Upvotes: 1

Views: 1727

Answers (1)

Michel Feinstein
Michel Feinstein

Reputation: 14276

Solved it by doing Tools | Resync with Remote Hosts.

Upvotes: 2

Related Questions