ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Problems using curl using Qtcreator (ROS-KINETIC)

asked 2018-03-06 05:43:03 -0600

Solrac3589 gravatar image

Hello everybody. I came here after doing research in this web (and others) and not finding a clear solution for me in the topic.

I am sorry if it is duplicated, but is searched this info a few times in the searcher and by tag (curl) and i did not find anything.

I have downloaded curl

sudo aptitude install libcurl4-openssl-dev

and I tried to do a small demo based on (which worked correctly outside ROS)

but doing it with ROS and QTCREATOR:

#include <ros/ros.h>
#include <iostream>
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;

int main(int argc, char** argv)

    ros::init(argc, argv, "Try");

      CURL *curl;
      CURLcode res;
      std::string readBuffer;

      curl = curl_easy_init();
      if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
        res = curl_easy_perform(curl);

        std::cout << readBuffer << std::endl;


    return 0;

It does not recognise many of the curl functions:

listener.cpp:(.text+0x3219): undefined reference to `curl_easy_init' 
listener.cpp:(.text+0x324c): undefined reference to `curl_easy_setopt' 
listener.cpp:(.text+0x326a): undefined reference to `curl_easy_setopt' 
listener.cpp:(.text+0x328a): undefined reference to `curl_easy_setopt' 
listener.cpp:(.text+0x3299): undefined reference to `curl_easy_perform'
listener.cpp:(.text+0x32ae): undefined reference to `curl_easy_cleanup'

curl library itself is found, and using control+click into the actions, it redirects to the desired definition.

Maybe is somethin simple, but i do not manage to understand the problem.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-09 13:41:35 -0600

duck-development gravatar image

You have to add libcurl in you cmake file as link dependency.

Something like this

target_link_libraries(MyExecutable curlpp)


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-03-06 05:43:03 -0600

Seen: 481 times

Last updated: Sep 09 '19