下载库:
http://www.gnu.org/software/libmicrohttpd/这里有简单的该库介绍以及使用方法(简略)。下载:$ svn checkout https://gnunet.org/svn/libmicrohttpd/使用手册:http://www.gnu.org/software/libmicrohttpd/microhttpd.pdf使用教程:http://www.gnu.org/software/libmicrohttpd/tutorial.pdf(使用手册和使用教程都是讲怎么用这个库的。使用手册主要是API的调用、参数意义以及调用例子、各数据结构等,使用教程是使用手册的补充,使用教程相当与大纲,使用手册相当与细则。)
libmicrohttpd库如果要有https/SSL/TLS的支持,需要libgcrypt和libgnutls库:http://www.gnupg.org/download/index.en.html#libgcryptftp://ftp.gnu.org/gnu/gnutls/我linux下,且要支持https。下载之。----------------------------------------------
安装依赖库:
1.安装libgcrypt库:$ ./configureconfigure: error: libgpg-error is needed. See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ 去ftp://ftp.gnupg.org/gcrypt/libgpg-error/下载libgpg-error, ./configure,make,sudo make install.继续对libgcrypt进行./configure,make,sudo make install.
2.安装libgnutls库:$ ./configureconfigure: error: *** *** Libnettle 2.4 was not found. You must compile nettle with gmp support.去ftp://ftp.lysator.liu.se/pub/security/lsh下载nettle,./configure,make,sudo make install.继续对libgnutls进行./configure,依然configure: error: *** *** Libnettle 2.4 was not found. You must compile nettle with gmp support.查看gnutls-3.0.19/README,有这么一句话:The library depends on libnettle and p11-kit. 去http://p11-glue.freedesktop.org/releases/下载p11-kit,./configure,make,sudo make install.对libgnutls进行./configure,依旧。。。日!“You must compile nettle with gmp support”?去http://gmplib.org/下载gmp。。。然后各种曲折,最后终于成功编好了gnutls库,这部分步骤如下:
$ cd p11-kit-0.12/$ ./configure$ make$ sudo make install$ cd gmp-5.0.5/$ ./configure这里可能会提示:checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
$ m4程序“m4”尚未安装。 您可以使用以下命令安装:sudo apt-get install m4$ sudo apt-get install m4$ ./configure$ make$ sudo make install$ cd nettle-2.4$ make clean #必须!
$ ./configure$ make$ sudo make install$ cd gnutls-3.0.19$ ./configure$ make$ sudo make install----------------------------------------------
安装目标libmicrohttpd库:
例行查看README文件,重要信息如下:If you are using Subversion, run "autoreconf -fi" to create configure.再例行查看INSTALL文件,重要信息如下:没有重要信息,这文件是默认创建的。估计是GNU packages的INSTALL模板。$ cd libmicrohttpd/$ sudo apt-get install autoconf$ sudo apt-get install libtool$ autoreconf -fi$ ./configure注意,如果之前make过,这里要make clean!再./configure,make,sudo make install之。----------------------------------------------
libmicrohttpd的测试用例需要的库:
libmicrohttpd源码里的测试用例会用到libcurl,zzuf和socat库,干脆把他们都装上。去http://curl.haxx.se/download.html下载curl库,去http://caca.zoy.org/wiki/zzuf下载zzur,去http://www.dest-unreach.org/socat/download/下载socat。编socat的时候,make时出了个插曲,需要sudo apt-get install yodl。------------------------------------------------
再编 libmicrohttpd :$ cd libmicrohttpd
$ make clean
$ autoreconf -fi
$ ./configure
configure: Configuration Summary: Operating System: linux-gnu libgcrypt: yes libcurl (testing): yes Target directory: /usr/local Messages: yes HTTP Authentic.: yes Postproc: yes HTTPS support: yes
configure: HTTPS subsystem configuration: License : LGPL only这些yes啊说明所有的依赖库和test case的依赖库都已安装来
$ sudo apt-get install texinfo #这个的make需要这个
$ make
$ sudo make install------------------------------------------------
检验库安装正确鸟:
$ cd libmicrohttpd/doc/examples$ vi Makefile
CC=g++ CFLAGS=-Wall LDFLAGS+=-ldl MyIncPath=/usr/local/include MyLibPath=/usr/local/lib MyLibsName=microhttpd _I=$(addprefix -I,$(subst :, ,$(MyIncPath))) _L=$(addprefix -L,$(subst :, ,$(MyLibPath))) _l=$(addprefix -l,$(subst :, ,$(MyLibsName))) all: ifdef name $(CC) $(CFLAGS) -o $(addsuffix .exec,$(name)) $(addsuffix .c,$(name)) $(_I) $(_L) $(_l) $(LDFLAGS) else @echo "usage:make name=hellobrowser" endif clean: rm -rf *.exec$ make name=hellobrowser$ ./hellobrowser.execerror while loading shared libraries: libmicrohttpd.so.10: cannot open shared object file: No such file or directory$ sudo vi /etc/ld.so.conf添加一行:/usr/local/lib$ sudo ldconfig使生效$ ./hellobrowser.exec打开浏览器输入http://localhost:8888出现“Hello, browser!”页面说明正确鸟~
end 4 have libmicrohttpd.
转载于:https://www.cnblogs.com/xiaouisme/archive/2012/05/23/2515151.html