好不容易从网上找了一个C++写Rest API的示例,一开始总是遇到编译出错。这里记录一下过程。
$ git clone git://github.com/JiYou/NipunTalukdarExamples.git
下载代码之后,首先需要安装libcurl.
到http://curl.haxx.se/download.html 这里下载代码。
比如curl-7.29.0.tar.gz
$ tar zxf curl-7.29.0.tar.gz
$ cd curl-7.29.0
$ ./configure; make ; make install
接着再安装libmircohttpd
http://ossm.utm.my/gnu/libmicrohttpd/
$ http://ossm.utm.my/gnu/libmicrohttpd/libmicrohttpd-0.9.25.tar.gz
$ tar zxf libmicrohttpd-0.9.25
$ cd libmicrohttpd-0.9.25
$ ./configure; make; make install
记住,还需要安装boost库。
http://blog.csdn.net/ju136/article/details/7921374
再编译C++示列代码。
$ cd NipunTalukdarExamples/cpp/restfrmwork
$ g++ httphandler.cpp strutil.cpp api.cpp executor.cpp MHD_config.h -lmicrohttpd -lboost_regex -I./ -o server