libwebsockets编译

发布于:2025-06-28 ⋅ 阅读:(19) ⋅ 点赞:(0)

#安装 libwebsocket
git clone https://github.com/warmcat/libwebsockets && \
mkdir libwebsockets/build && cd libwebsockets/build && \
cmake -DMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. && \
make && make install

make错误:

In file included from /opt/projects/open/libwebsockets/lib/plat/unix/unix-sockets.c:31:
/usr/include/linux/ipv6.h:19:8: 错误:‘struct in6_pktinfo’重定义
   19 | struct in6_pktinfo {
      |        ^~~~~~~~~~~
In file included from /opt/projects/open/libwebsockets/lib/plat/unix/./private-lib-plat-unix.h:31,
                 from /opt/projects/open/libwebsockets/lib/core/./private-lib-core.h:138,
                 from /opt/projects/open/libwebsockets/lib/plat/unix/unix-sockets.c:28:
/usr/include/netinet/in.h:538:8: 附注:原先在这里定义
  538 | struct in6_pktinfo
      |        ^~~~~~~~~~~
In file included from /opt/projects/open/libwebsockets/lib/plat/unix/unix-sockets.c:31:
/usr/include/linux/ipv6.h:24:8: 错误:‘struct ip6_mtuinfo’重定义
   24 | struct ip6_mtuinfo {
      |        ^~~~~~~~~~~
In file included from /opt/projects/open/libwebsockets/lib/plat/unix/./private-lib-plat-unix.h:31,
                 from /opt/projects/open/libwebsockets/lib/core/./private-lib-core.h:138,
                 from /opt/projects/open/libwebsockets/lib/plat/unix/unix-sockets.c:28:
/usr/include/netinet/in.h:545:8: 附注:原先在这里定义
  545 | struct ip6_mtuinfo

修改

vi /opt/projects/open/libwebsockets/lib/plat/unix/unix-sockets.c
注释掉//#include <linux/ipv6.h>

cmake要修改为

cmake ..   -DCMAKE_INSTALL_PREFIX=/usr   -DCMAKE_C_FLAGS="-fPIC -Wno-error=sign-conversion -Wno-error"   -DLWS_WITH_WERROR=OFF


网站公告

今日签到

点亮在社区的每一天
去签到