玩转libuv之windows

1.编译库文件


tar -zxvf libuv-1.8.0.tar.gz

cd libuv-1.8.0

sed -i s"/CC ?= gcc/CC = gcc/" Makefile.mingw

mingw32-make -f Makefile.mingw

cd ..

2.编译基于libuv的tinyweb程序


unzip tinyweb-master.zip

cd tinyweb-master/test/

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

echo """
all: web1 web2 web3
web1:main1.c ../tinyweb1.c ../membuf.c
gcc $^ -o $@ -I./include -I../ -L. -luv -lws2_32 -lpsapi -liphlpapi -luserenv   

web2:main2.c ../tinyweb2.c ../membuf.c
gcc $^ -o $@ -I./include -I../ -L. -luv -lws2_32 -lpsapi -liphlpapi -luserenv

web3:main3.c ../tinyweb3.c ../membuf.c
gcc $^ -o $@ -I./include -I../ -L. -luv -lws2_32 -lpsapi -liphlpapi -luserenv

.PHONY:clean
clean:
@rm -rf web*.exe
""" >Makefile

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

mingw32-make