玩转libuv之linux

1.编译库文件


tar -zxvf libuv-1.8.0.tar.gz
cd libuv-1.8.0

./autogen.sh
./configure
make
#make check
#make install

cd ..

2.编译基于libuv的tinyweb程序


unzip tinyweb-master.zip

cd tinyweb-master/test/

cp ../../libuv-1.8.0/.libs/libuv.a ./
cp ../../libuv-1.8.0/include/ ./ -a

echo """
all: web1 web2 web3
web1:main1.c ../tinyweb1.c ../membuf.c
    gcc $^ -o $\@ -I./include -I../ -L. -luv -lpthread

web2:main2.c ../tinyweb2.c ../membuf.c
    gcc $^ -o $\@ -I./include -I../ -L. -luv -lpthread

web3:main3.c ../tinyweb3.c ../membuf.c
    gcc $^ -o $\@ -I./include -I../ -L. -luv -lpthread

.PHONY:clean
clean:
    @rm -rf $(all)
""">Makefile

sed -i s"/gcc/\tgcc/" Makefile
sed -i s"/@rm/\t@rm/" Makefile
sed -i s"/$\\\@/$\@/" Makefile

make