(Formerly) Compile the microhttpd library in Linux (a C/C ++ HTTP server Library)

Source: Internet
Author: User
Tags gmp gnupg


Download Library:



Http://www.gnu.org/software/libmicrohttpd/
Here is a brief introduction to this library and how to use it (simple ).
Download:
$ SVN checkout https://gnunet.org/svn/libmicrohttpd/
User Manual:
Http://www.gnu.org/software/libmicrohttpd/microhttpd.pdf
Tutorial:
Http://www.gnu.org/software/libmicrohttpd/tutorial.pdf
(Both the user manual and user guide talk about how to use this library. The user manual mainly refers to API calls, parameter meanings, call examples, and data structures. The user guide is a supplement to the user manual. The user guide is equivalent to the outline, and the user manual is equivalent to the detailed rules .)



If the libmicrohttpd Library requires https/SSL/TLS support, libgcrypt and libgnutls libraries are required:
Http://www.gnupg.org/download/index.en.html#libgcrypt
Ftp://ftp.gnu.org/gnu/gnutls/
I want to support HTTPS in Linux. Download it.
----------------------------------------------



 



Install the dependency Library:



1. Install the libgcrypt Library:
$./Configure
Configure: Error: libgpg-error is needed.
See ftp://ftp.gnupg.org/gcrypt/libgpg-error/
Go to ftp://ftp.gnupg.org/gcrypt/libgpg-error/download libgpg-error,./configure, make, sudo make install.
Continue libgcrypt./configure, make, sudo make install.



2. Install the libgnutls Library:
$./Configure
Configure: Error:
***
* ** Libnettle 2.4 was not found. You must compile nettle with GMP support.
Go to ftp://ftp.lysator.liu.se/pub/security/lshto download nettle,./configure,make,sudo make install.
Continue to perform./configure for libgnutls, still
Configure: Error:
***
* ** Libnettle 2.4 was not found. You must compile nettle with GMP support.
View the gnutls-3.0.19/readme, with the following sentence:
The library depends on libnettle and p11-kit.
Go to http://p11-glue.freedesktop.org/releases/download p11-kit,./configure,make,sudo make install.
Perform./configure on libgnutls, and still... Day!
"You must compile nettle with GMP support "?
Go to http://gmplib.org/to download gmp1_logs... Then various twists and turns finally succeeded in compiling the gnutls library. The steps are as follows:



$ CD p11-kit-0.12/
$./Configure
$ Make
$ Sudo make install



$ CD gmp-5.0.5/
$./Configure



The following message may be displayed:
Checking for suitable m4... configure: Error: no usable M4 in $ path or/usr/5bin (see config. log for reasons ).



$ M4
Program"M4" is not installed yet. You can use the following command to install:
Sudo apt-Get install M4
$ Sudo apt-Get install M4
$./Configure



$ Make
$ Sudo make install



$ CD Nettle-2.4
$ Make clean # required!



$./Configure
$ Make
$ Sudo make install
$ Gnutls-3.0.19 CD
$./Configure
$ Make
$ Sudo make install
----------------------------------------------



Install the libmicrohttpd Library:



The readme file is routinely viewed. The important information is as follows:
If you are using subversion, Run "autoreconf-fi" to create configure.
Check the install file as follows:
No important information. This file is created by default. It is probably the install template of GNU packages.
$ CD libmicrohttpd/
$ Sudo apt-Get install Autoconf
$ Sudo apt-Get install libtool
$ Autoreconf-fi
$./Configure
Note: If you have made it before, make clean here! Again./configure, make, sudo make install.
----------------------------------------------



Library required for libmicrohttpd test cases:



The libcurl, zzuf, and socat libraries are used for testing in the libmicrohttpd source code, and they are all installed.
Go to http://curl.haxx.se/download.htmlto download the curllibrary,
Go to http://caca.zoy.org/wiki/zzufto download zzur,
Go to http://www.dest-unreach.org/socat/download/download socat.
When compiling socat, make has an episode and requires sudo apt-Get install yodl.
------------------------------------------------



Edit libmicrohttpd again:



$ 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, it indicates that all dependent libraries and test case dependent libraries have been installed.



$Sudo apt-Get install texinfo # Make needs this



$ Make



$ Sudo make install
------------------------------------------------



Verify that the Library is correctly installed:



$ 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.exe C
Error while loading shared libraries: libmicrohttpd. so.10: cannot open shared object file: no such file or directory
$Sudo VI/etc/lD. So. conf
Add a row:/Usr/local/lib
$SudoLdconfigMake effective
$./Hellobrowser.exe C
Open the browser and enter http: // localhost: 8888. "Hello, browser!" appears !" The page description is correct ~



End 4 have libmicrohttpd.



 



 



 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.