(原)linux下编译microhttpd库(一个c/c++的http服务端库)
2012-05-23 17:56
323 查看
下载库:
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#libgcrypt ftp://ftp.gnu.org/gnu/gnutls/
我linux下,且要支持https。下载之。
----------------------------------------------
安装依赖库:
1.安装libgcrypt库:
$ ./configure
configure: 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库:
$ ./configure
configure: 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
$ make name=hellobrowser
$ ./hellobrowser.exec
error 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.
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#libgcrypt ftp://ftp.gnu.org/gnu/gnutls/
我linux下,且要支持https。下载之。
----------------------------------------------
安装依赖库:
1.安装libgcrypt库:
$ ./configure
configure: 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库:
$ ./configure
configure: 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.exec
error 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.
相关文章推荐
- 在Linux平台下如何编译一个C++工程
- 关于如何在make一个Linux下的C/C++工程时,自动添加版本号、编译日期等信息
- 在Linux平台下如何编译一个C++工程
- 在linux环境下编译一个c/c++工程
- 在linux环境下编译一个c/c++工程
- 在Linux平台下如何编译一个C++工程
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- 利用winelib编译一个可在linux下运行的程序
- linux下编译多个C/C++文件
- permake4 linux编译C++项目
- 如何编写并编译一个shellcode(linux)
- 在linux下如何编译C++程序
- 一个神奇的网站 http://linux.linuxidc.com/
- linux 环境下c,c++编程(三):c++的编译文件
- 在Linux中使用VS Code编译调试C++项目
- linux下交叉编译libusb的方法及编译一个使用了libusb库的test程序的方法
- linux下编译C++程序
- LINUX下简单的编译和使用动态链接库[compile .so use c++ in linux]
- 一个最简单的linux驱动程序的编译运行
- 一个简单的linux环境下C编译