MinGW 编译libwebsockets

 

 

libwebsockets是一个轻量的纯C库,在这里尝试使用MinGW进行构建。

 

官网地址:http://libwebsockets.org/trac/libwebsockets
下载地址:http://git.warmcat.com/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.22-chrome26-firefox18.tar.gz

首先,搭建MSYS2环境,参见文章《MSYS2 环境搭建》,编译之前得有autoconf、automake、libtool、make工具,使用命令pacman -S 命令进行安装,然后cd到库目录,使用如下命令:

./autogen.sh
./configure --prefix=/mingw32 --enable-mingw --without-daemonize --without-testapps
make
make install
其中,参数--without-daemonize --without-testapps是因为在windows下MinGW32编译不过,找不到相关定义等。(FIXME)

完成之后,就可以生成libwebsockets.a文件了。

接着,在"E:\msys32\mingw32\include"目录下,新建win32helpers文件夹,复制"libwebsockets-1.22-chrome26-firefox18\win32port\win32helpers"文件夹下的websock-w32.h文件到此文件夹下。
编辑E:\msys32\mingw32\include\libwebsockets.h文件,更改以下两行:


#include "win32helpers/websock-w32.h"

//#include "win32helpers/gettimeofday.h"
完成。
————————————————
版权声明:本文为CSDN博主「无幻」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/akof1314/article/details/18183911

posted @ 2020-06-24 11:45  阳光下的小土豆  阅读(507)  评论(0编辑  收藏  举报