tree: 2de27e0c70e4ebaf1c1a11af3471bbbbf0ee3fb7 [path history] [tgz]
  1. base64.c
  2. base64.h
  3. CMakeLists.txt
  4. main.c
  5. README.md
example/rest-client-c-example/README.md

a complete C rest client demo project

project structure

  • base64.c/base64.h: a util for base64.encode/decode

  • main.c: call the rest api for IoTDB

How to build

dependency: libcurl

  • example: Ubuntu 16.04 STL (Ubuntu 20.04 may have some problems)
sudo apt-get install libcurl4-openssl-dev

Before build, you must install the libcurl.

build steps:

mkdir build
cd build
cmake ..
make 

Eventually, you will get an executable program c_rest_iotdb in build directory.

cross compilation

  • os : Ubuntu 16.04 STL
  1. choose and install cross compiler according to the target host

arm-linux-gnueabihf-gcc as an example.

  • arm-linux-gnueabihf-gcc
sudo apt-get install gcc-arm-linux-gnueabihf
  1. cross compile libcurl
./configure --host=arm-linux/arm-linux-gnueabihf/others CC=arm-linux-gnueabihf-gcc --prefix=`install dir` --enable-static --with-wolfssl
make
make install
  1. cross compile the example program
arm-linux-gnueabihf-gcc main.c base64.c -o c_rest -L `(libcurl install dir)/lib/` -l curl

if can't find curl/curl.h, you can just simply change to the absolutely path or specify the include path.

Reference Materials

libcurl usage:

https://blog.csdn.net/myvest/article/details/82899788

compilation:

https://blog.csdn.net/u011641885/article/details/46900771

https://www.cnblogs.com/flyinggod/p/10148228.html

https://blog.csdn.net/fangye945a/article/details/86500817

https://www.cnblogs.com/yxh-l-0824/p/13254891.html

https://www.cnblogs.com/tansuoxinweilai/p/11602830.html

https://www.cnblogs.com/pied/p/8805883.html