ARM平臺移植libcurl curl-7.49.0
An example source code that issues a HTTP POST and we provide the actual data through a read callback. |
[[email protected]]# arm-none-linux-gnueabi-g++ -lcurl -I/home/kt/libcurl/include -L/home/kt/libcurl/lib -o libcurl_test libcurl.cpp#include <stdio.h> #include <string.h> #include <curl/curl.h> const char data[]="this is what we post to the silly web server"; struct WriteThis { const char *readptr; long sizeleft; }; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { struct WriteThis *pooh = (struct WriteThis *)userp; if(size*nmemb < 1) return 0; if(pooh->sizeleft) { *(char *)ptr = pooh->readptr[0]; /* copy one single byte */ pooh->readptr++; /* advance pointer */ pooh->sizeleft--; /* less data left */ return 1; /* we return 1 byte at a time! */ } return 0; /* no more data left to deliver */ } int main(void) { CURL *curl; CURLcode res; struct WriteThis pooh; pooh.readptr = data; pooh.sizeleft = (long)strlen(data); /* In windows, this will init the winsock stuff */ res = curl_global_init(CURL_GLOBAL_DEFAULT); /* Check for errors */ if(res != CURLE_OK) { fprintf(stderr, "curl_global_init() failed: %s\n", curl_easy_strerror(res)); return 1; } /* get a curl handle */ curl = curl_easy_init(); if(curl) { /* First set the URL that is about to receive our POST. */ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/index.cgi"); /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* pointer to pass to our read function */ curl_easy_setopt(curl, CURLOPT_READDATA, &pooh); /* get verbose debug output please */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* If you use POST to a HTTP 1.1 server, you can send data without knowing the size before starting the POST if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you must specify the size in the request. */ #ifdef USE_CHUNKED { struct curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked"); res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); /* use curl_slist_free_all() after the *perform() call to free this list again */ } #else /* Set the expected POST size. If you want to POST large amounts of data, consider CURLOPT_POSTFIELDSIZE_LARGE */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); #endif #ifdef DISABLE_EXPECT /* Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with CURLOPT_HTTPHEADER as usual. NOTE: if you want chunked transfer too, you need to combine these two since you can only set one list of headers with CURLOPT_HTTPHEADER. */ /* A less good option would be to enforce HTTP 1.0, but that might also have other implications. */ { struct curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Expect:"); res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); /* use curl_slist_free_all() after the *perform() call to free this list again */ } #endif /* 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); } curl_global_cleanup(); return 0; }
編譯通過,在當前目錄生成libcurl_test可執行檔案
相關推薦
ARM平臺移植libcurl curl-7.49.0
編譯test例項 https://curl.haxx.se/libcurl/c/example.html An example source code that issues a HTTP POST and we provide the actual data through a read cal
Beego+go-sqlite3 Arm平臺移植遇到的問題
交叉 提示 found win beego windows 平臺移植 linux lin 在windows下使用Beego+go-sqlite3進行簡單博客開發, 但編譯後將其植入Arm平臺下運行異常:編譯參數設置: SET GOARCH=armSET GOOS=linux
[Linux] ARM平臺移植通常依賴的庫
ARM-Linux平臺移植通常依賴的庫 sudo apt-get install make sudo apt-get install gcc-arm-linux-gnueabi(按實際情況選擇安裝) sudo apt-get install g++ sudo a
ARM平臺移植 openssl-1.1.1
openssl 新版本 config 變化較大 openssl-OpenSSL_1_1_1-stable.zip ./config no-asm shared --prefix=/home/H1Ne shared no-asm 在交叉編譯過程中不使
curl 7.63.0 釋出,用 URL 傳輸資料的命令列工具和庫
curl 7.63.0 釋出了,此版本主要更新如下: curl: --write-out 新增 %{stderr} 和 %{stdout} curl: win32 新增選項 --dump-module-paths setopt: 新增 
ubuntu16.04 ARM平臺移植xmlrpc-c
1. xmlrpc-c依賴與libcurl 參考另外一篇隨筆:https://www.cnblogs.com/flyinggod/p/10148228.html 2. 下載原始碼 http://xmlrpc-c.sourceforge.net/ 3. 編譯程式碼 ./configure
curl-7.39.0 for android 編譯以及jni中的使用
因為有需求需要編譯libcurl庫在android工程中使用,所以首先就需要自己編譯一個libcurl.a或者libcurl.so了,因為它用的很廣泛嘛; 另外如果一個curl庫要支援ssl,必須要在編譯的時候和ssl組合編譯,比如openssl; 瞭解了這些以後,就可以
valgrind的arm平臺移植
wget ftp://sourceware.org/pub/valgrind/valgrind-3.13.0.tar.bz2 因為我的glib比較新,所以valgrind原始碼下了個當前的最新版本,否則編譯的時候會提示不支援 tar xvf valgrind-3.13.0
Cocos2d-x v3.0正式版嘗鮮體驗【2】 Android平臺移植
生成 ble ack nts 做的 導入 eclipse so文件 腳本 今天沒事又嘗試了下3.0正式版關於Android平臺的移植,把新建的項目移植了下。過程僅用了十分鐘左右,什麽概念?!好吧,事實上我想說,這個版本號真的移植非常輕松啊,只是還沒加上其它東西,只是就眼
我遇到的錯誤curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused
ace bsp port style connect col socks 註釋 ref 今天我用curl命令,無論如何都是出現: curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused 找
用arm-linux-gnueabihf移植MP3播放器libmad-0.15.1b的時候出現錯誤提示
移植 else /dev/null -- b- line .com ibm fail diff --git a/package/libmad/libmad-0.15.1b-thumb2-fixed-arm.patch b/package/libmad/libmad-0.15
Docker錯誤 curl: (7) Failed to connect to 127.0.0.1 port 32768: Connection refused
首先我宣告一下,由於我的windows是家庭版,所以我用的是Docker Toolbox 今天試了試Docker,搞了個容器, 想在容器裡面執行一個靜態網頁,於是在容器裡面下載了nginx,下載了vim 然後修改了nginx的配置檔案 我ctrl+p q掛起容器後臺執行 一切順風
ubuntu移植libcurl到Android平臺
簡書排版 http://www.jianshu.com/p/332011ebd6e5 最近移植了很多C++平臺的庫,很多都是後臺開發的庫,因為NDK開發,以後很可能會使用,提前預研一下。 libcurl這個庫很有名,用的人比較多,下載原始碼,直接就可以編譯使用,以前在Windows平
ARM平臺上藍芽協議棧Bluez的移植使用和配置(寫的狠不錯) .
目錄(?)[-] 相關說明 網站資源 工作環境 編譯 核心 Bluez Lib / Utils 藍芽硬體初始化及基礎服務啟動 何謂硬體初始化 硬體初始化步驟
qt5.9.7 移植到qnx 7.0
網上有一篇針對qt 4的 針對的是qnx6.6,很多配置引數也對應不上,總結一下我移植qt 5.9.7 到qnx7.0的過程 移植qt4.8到qnx 首先我的系統是Ubuntu 16.04.02 + qnx 7.0 + qt 5.9.7 1.準備工作: 1
用模擬器載入基於ARM平臺的WinCE6 0 核心(NK bin)
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
移植ethtool到arm平臺
轉載地址:https://blog.csdn.net/crazycoder8848/article/details/44278791 轉載地址:https://blog.csdn.net/vc66vcc/article/details/52398864 首先下載ethtool的原始碼包。
live555本機和arm平臺的移植
本文講解在PC和arm平臺上進行live555的移植,目標平臺使用全志A20。 1、原始碼下載 可以登陸live555的官網獲取live555最新版原始碼,也可從下面這個地址獲取到本文移植所使用的原始碼: 2、編譯 (1)PC編譯 解壓原始
linux環境下ARM移植libcurl
因為用的板子是ZLG的imx280a,所以我安裝的Ubuntu直接用他們給的了。 系統環境:VM-Ubuntu-12.04-64bit-zlg(這個無所謂,我直接用的ZLG官方給的映象安裝的) libcurl的安裝包:curl-7.55.1.tar(這是我做的時候出的最
ARM平臺上藍芽協議棧Bluez的移植使用和配置
作者:劉旭暉 Raymond轉載請註明出處 主頁:http://rgbbones.googlepages.com/ Bluez作為當前最成熟的開源藍芽協議棧,在Linux的各大發行版中已