The libwebsockets example provides the following compilation methods
cmake . && make
The compilation method of the code written by yourself is as follows
gcc -o server main.c -lwebsockets
The result is an error:
./server : error while loading shared libraries: libwebsockets.so.17: cannot open shared object file: No such file or directory
Solution:
If you've installed libwebsockets with make install then you probably just need to run sudo ldconfig to update the linker cache.
Execute the following command
sudo ldconfig
error: conversion to ‘long int’ from ‘long unsigned int’ may change the sign of the result
Comment out the content below line 736 of CMakeLists.txt
# if ("${DISABLE_WERROR}" STREQUAL "OFF")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
# endif()