linux 에서 program 을 작성할 때, 웹의 데이터를 가져오려 할 경우, curl 을 쓰면 편하다.
curl 은 http, https, ftp 등의 데이터를 다룰 수 있게 해 준다.
헌데.... 설치법을 잘 모르겠어. OTL.
curl 사이트( http://curl.haxx.se/docs/install.html ) 를 뚫어지게 보다가.... 갑자기 생각나서 콘솔에서 yum 을 쳐봤다.
#yum install curl
만쉐이!! 진행된다!!
그런데, 실제로 curl 사이트에서 예제 파일을 작성해 보면, 컴파일 안됨.
알고보니, curl 은 실행용 binary 가 있고, 개발용 library 가 있는데, 그냥 yum install curl 하면 binary 만 깔리는 거임.
yum install groupinstall curl 해도 안된다.
결론은
#yum install curl-devel
하면 된다.
아래는 curl 에서 가져온, 컴파일 테스트를 위한 hello world 파일이다. ( 출처 : http://curl.haxx.se/libcurl/c/simple.html )
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
컴파일 할 때는
# gcc curltest.c -lcurl
과 같이 curl 을 추가해 주자.
추가 : 만일 다른 리눅스 버전에서 yum , apt-get 등으로 curl-devel 이 안 되면, 패키지 이름을 이하의 내용으로 시도해 볼 것.
curl-devel
curl-dev
libcurl
libcurl3
libcurl4
libcurl-openssl-dev
libcurl4-openssl-dev
이거 해도 안되면? 나도모름.
'프로그램' 카테고리의 다른 글
| javascript location.href vs location.assign vs location.replace (0) | 2013.11.22 |
|---|---|
| cafe24 에 접속이 안 될 때. (0) | 2013.11.08 |
| 아래한글 hwp 2007 뷰어 (0) | 2013.10.31 |
| 크롬 윈도우 창이 window.close() 로 안 닫힐때. (0) | 2013.09.14 |
| 다음에 메일 전송이 안될 때. (0) | 2013.08.18 |