CLion中的lcurl问题 [英] Problems with lcurl in CLion

查看:455
本文介绍了CLion中的lcurl问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CLion的新手,我想提高自己在libcurl中的技能.我已经在Ubuntu 15.04上安装了libcurl4-openssl-dev.我的CMakeLists.txt:

i'm new in CLion and i want to improve my skills in libcurl. I have installed libcurl4-openssl-dev on Ubuntu 15.04. My CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(test)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lcurl")
set(SOURCE_FILES main.cpp)
add_executable(test ${SOURCE_FILES}) 

但是当我尝试这样做时:

But when i try this:

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

using namespace std;

int main() 
{
    CURL *curl;
    CURLcode result;
    curl = curl_easy_init();
    return 0;
}

他向我展示了这样的错误:

He shows me such error:

/home/me/ClionProjects/test/main.cpp:10: undefined reference to `curl_easy_init'

请帮帮我, 谢谢

推荐答案

感谢@sjsam. 解决方法是(CMakeLists.txt):

Thanks to @sjsam. The solution is(CMakeLists.txt):

cmake_minimum_required(VERSION 3.3)
project(example)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lcurl")

set(SOURCE_FILES main.cpp)
add_executable(example ${SOURCE_FILES})
target_link_libraries(example curl)

这篇关于CLion中的lcurl问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆