[英]Including libcurl in C project
這是我的第一個C程序,我在他們的網站上使用這個示例libcurl代碼:
#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, "https://google.com/");
#ifdef SKIP_PEER_VERIFICATION
/*
* If you want to connect to a site who isn't using a certificate that is
* signed by one of the certs in the CA bundle you have, you can skip the
* verification of the server's certificate. This makes the connection
* A LOT LESS SECURE.
*
* If you have a CA cert for the server stored someplace else than in the
* default bundle, then the CURLOPT_CAPATH option might come handy for
* you.
*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERFICATION
/*
* If the site you're connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip
* this check, but this will make the connection less secure.
*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
所以在xcode中我創建了一個名為curl的“組”並添加了curl目錄中的所有文件:
現在我收到這些Build錯誤:
我究竟做錯了什么? 任何建議都會有所幫助,謝謝!
對於Xcode 4.5:
現在,當你構建它應該能夠鏈接到庫。
Mac OS X附帶了libcurl的副本,因此您的應用程序不需要自己的副本。
你沒有提到你正在使用的Xcode版本。 以下內容適用於3.2,但可能不適用於4。
要使用系統提供的libcurl版本,請轉到“ Project
,然后選擇“ Add To Project
。 在出現的對話框中,鍵入/usr/lib
並按Enter鍵。 在文件列表中找到libcurl.dylib
,然后單擊“ Add
。
對於XCode 7,只需右鍵單擊要放入lib的項目或組,然后選擇Add Files to "Project Name"...
,最后在/usr/lib
目錄中找到libcurl.dylib
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.