Compile and test methods latest libwebsockets library

1. Environment

In Ubuntu TLS 16.4.5 version to compile and test.

Download the latest source code needs to git, git if not installed can use the following command to install:

sudo apt-get install git -y

Also, there are compile dependencies, associated installation command as follows:

sudo apt-get install cmake -y
sudo apt-get install openssl -y
sudo apt-get install libssl-dev -y

2. Compile and install

2.1 Download Source

git clone https://github.com/warmcat/libwebsockets.git

2.2 into the source directory

cd libwebsockets

2.3 Create a build directory and execute CMake

Create a build directory build, and enter the relevant commands as follows:

mkdir build
cd build

Execute cmake, the command is as follows:

cmake ..

The results are as follows:

cgs@ubuntu:~/libwebsockets/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMAKE_TOOLCHAIN_FILE=''
-- Found Git: /usr/bin/git  
Git commit hash: v3.1.0-65-gafbf40c
-- Performing Test LWS_HAVE_inline
-- Performing Test LWS_HAVE_inline - Success
-- Performing Test LWS_HAVE___inline__
-- Performing Test LWS_HAVE___inline__ - Success
-- Performing Test LWS_HAVE___inline
-- Performing Test LWS_HAVE___inline - Success
-- Performing Test LWS_HAVE_BZERO
-- Performing Test LWS_HAVE_BZERO - Success
-- Looking for fork
-- Looking for fork - found
-- Looking for getenv
-- Looking for getenv - found
-- Looking for malloc
-- Looking for malloc - found
-- Looking for memset
-- Looking for memset - found
-- Looking for realloc
-- Looking for realloc - found
-- Looking for socket
-- Looking for socket - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for vfork
-- Looking for vfork - found
-- Looking for execvpe
-- Looking for execvpe - found
-- Looking for getifaddrs
-- Looking for getifaddrs - found
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for _snprintf
-- Looking for _snprintf - not found
-- Looking for _vsnprintf
-- Looking for _vsnprintf - not found
-- Looking for getloadavg
-- Looking for getloadavg - found
-- Looking for atoll
-- Looking for atoll - found
-- Looking for _atoi64
-- Looking for _atoi64 - not found
-- Looking for _stat32i64
-- Looking for _stat32i64 - not found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for in6addr.h
-- Looking for in6addr.h - not found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for netinet/in.h
-- Looking for netinet/in.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for sys/prctl.h
-- Looking for sys/prctl.h - found
-- Looking for sys/socket.h
-- Looking for sys/socket.h - found
-- Looking for sys/sockio.h
-- Looking for sys/sockio.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for vfork.h
-- Looking for vfork.h - not found
-- Looking for sys/capability.h
-- Looking for sys/capability.h - not found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for cap_set_flag in cap
-- Looking for cap_set_flag in cap - not found
-- Looking for 4 include files stdlib.h, ..., float.h
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Performing Test LWS_HAS_INTPTR_T
-- Performing Test LWS_HAS_INTPTR_T - Success
-- Performing Test LWS_HAS_PTHREAD_SETNAME_NP
-- Performing Test LWS_HAS_PTHREAD_SETNAME_NP - Success
-- Performing Test LWS_HAS_GETOPT_LONG
-- Performing Test LWS_HAS_GETOPT_LONG - Success
-- Performing Test LWS_HAVE_VISIBILITY
-- Performing Test LWS_HAVE_VISIBILITY - Success
Compiling with SSL support
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2g") 
OpenSSL include dir: /usr/include
OpenSSL libraries: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
-- Looking for openssl/ecdh.h
-- Looking for openssl/ecdh.h - found
-- Looking for SSL_CTX_set1_param
-- Looking for SSL_CTX_set1_param - found
-- Looking for SSL_set_info_callback
-- Looking for SSL_set_info_callback - found
-- Looking for X509_VERIFY_PARAM_set1_host
-- Looking for X509_VERIFY_PARAM_set1_host - found
-- Looking for RSA_set0_key
-- Looking for RSA_set0_key - not found
-- Looking for X509_get_key_usage
-- Looking for X509_get_key_usage - not found
-- Looking for SSL_CTX_get0_certificate
-- Looking for SSL_CTX_get0_certificate - found
-- Looking for SSL_get0_alpn_selected
-- Looking for SSL_get0_alpn_selected - found
-- Looking for SSL_set_alpn_protos
-- Looking for SSL_set_alpn_protos - found
-- Looking for SSL_CTX_set_ciphersuites
-- Looking for SSL_CTX_set_ciphersuites - not found
-- Looking for SSL_CTX_get_extra_chain_certs_only
-- Looking for SSL_CTX_get_extra_chain_certs_only - found
-- Looking for EVP_MD_CTX_free
-- Looking for EVP_MD_CTX_free - not found
-- Looking for ECDSA_SIG_set0
-- Looking for ECDSA_SIG_set0 - not found
-- Looking for BN_bn2binpad
-- Looking for BN_bn2binpad - not found
-- Looking for EVP_aes_128_wrap
-- Looking for EVP_aes_128_wrap - found
-- Looking for TLS_client_method
-- Looking for TLS_client_method - not found
-- Looking for TLSv1_2_client_method
-- Looking for TLSv1_2_client_method - found
-- Performing Test LWS_HAVE_PIPE2
-- Performing Test LWS_HAVE_PIPE2 - Success
-- Performing Test LWS_HAVE_TCP_USER_TIMEOUT
-- Performing Test LWS_HAVE_TCP_USER_TIMEOUT - Success
Searching for OpenSSL executable and dlls
OpenSSL executable: /usr/bin/openssl
 GENCERTS = 1
Generating SSL Certificates for the test-server...
Generating a 1024 bit RSA private key
....................................................++++++
....++++++
writing new private key to '/home/cgs/workspace/libwebsockets/build/libwebsockets-test-server.key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:SUCCESSFULLY generated SSL certificate
-- Looking for RPMTools... - rpmbuild NOT FOUND
---------------------------------------------------------------------
  Settings:  (For more help do cmake -LH <srcpath>)
---------------------------------------------------------------------
 LWS_WITH_STATIC = ON
 LWS_WITH_SHARED = ON
 LWS_WITH_SSL = ON (SSL Support)
 LWS_SSL_CLIENT_USE_OS_CA_CERTS = 1
 LWS_WITH_WOLFSSL = OFF (wolfSSL/CyaSSL replacement for OpenSSL)
 LWS_WITH_MBEDTLS = OFF (mbedTLS replacement for OpenSSL)
 LWS_WITHOUT_BUILTIN_SHA1 = OFF
 LWS_WITHOUT_BUILTIN_GETIFADDRS = OFF
 LWS_WITHOUT_CLIENT = OFF
 LWS_WITHOUT_SERVER = OFF
 LWS_LINK_TESTAPPS_DYNAMIC = OFF
 LWS_WITHOUT_TESTAPPS = OFF
 LWS_WITHOUT_TEST_SERVER = OFF
 LWS_WITHOUT_TEST_SERVER_EXTPOLL = OFF
 LWS_WITHOUT_TEST_PING = OFF
 LWS_WITHOUT_TEST_CLIENT = OFF
 LWS_WITHOUT_EXTENSIONS = ON
 LWS_WITH_LATENCY = OFF
 LWS_WITHOUT_DAEMONIZE = ON
 LWS_WITH_LIBEV = OFF
 LWS_WITH_LIBUV = OFF
 LWS_WITH_LIBEVENT = OFF
 LWS_IPV6 = OFF
 LWS_UNIX_SOCK = OFF
 LWS_WITH_HTTP2 = 1
 LWS_SSL_SERVER_WITH_ECDH_CERT = OFF
 LWS_MAX_SMP = 1
 LWS_HAVE_PTHREAD_H = 1
 LWS_WITH_CGI = OFF
 LWS_HAVE_OPENSSL_ECDH_H = 1
 LWS_HAVE_SSL_CTX_set1_param = 1
 LWS_HAVE_RSA_SET0_KEY = 
 LWS_WITH_HTTP_PROXY = OFF
 LIBHUBBUB_LIBRARIES = 
 PLUGINS = 
 LWS_WITH_ACCESS_LOG = OFF
 LWS_WITH_SERVER_STATUS = OFF
 LWS_WITH_LEJP = ON
 LWS_WITH_LEJP_CONF = ON
 LWS_WITH_SMTP = OFF
 LWS_WITH_GENERIC_SESSIONS = OFF
 LWS_STATIC_PIC = OFF
 LWS_WITH_RANGES = OFF
 LWS_PLAT_OPTEE = OFF
 LWS_WITH_ESP32 = OFF
 LWS_WITH_ZIP_FOPS = OFF
 LWS_AVOID_SIGPIPE_IGN = OFF
 LWS_WITH_STATS = OFF
 LWS_WITH_SOCKS5 = OFF
 LWS_HAVE_SYS_CAPABILITY_H = 
 LWS_HAVE_LIBCAP = 
 LWS_WITH_PEER_LIMITS = OFF
 LWS_HAVE_ATOLL = 1
 LWS_HAVE__ATOI64 = 
 LWS_HAVE_STAT32I64 = 
 LWS_HAS_INTPTR_T = 1
 LWS_WITH_EXPORT_LWSTARGETS = ON
---------------------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cgs/workspace/libwebsockets/build

2.4 compiler

Compiler command is as follows:

make

The results are as follows:

cgs@ubuntu:~/libwebsockets/build$ make
Scanning dependencies of target websockets
[  1%] Building C object CMakeFiles/websockets.dir/lib/core/alloc.c.o
[  2%] Building C object CMakeFiles/websockets.dir/lib/core/context.c.o
[  3%] Building C object CMakeFiles/websockets.dir/lib/core/libwebsockets.c.o
[  3%] Building C object CMakeFiles/websockets.dir/lib/core/logs.c.o
[  4%] Building C object CMakeFiles/websockets.dir/lib/misc/base64-decode.c.o
[  5%] Building C object CMakeFiles/websockets.dir/lib/core/vfs.c.o
[  6%] Building C object CMakeFiles/websockets.dir/lib/misc/lws-ring.c.o
[  6%] Building C object CMakeFiles/websockets.dir/lib/core-net/dummy-callback.c.o
[  7%] Building C object CMakeFiles/websockets.dir/lib/core-net/output.c.o
[  8%] Building C object CMakeFiles/websockets.dir/lib/core-net/close.c.o
[  9%] Building C object CMakeFiles/websockets.dir/lib/core-net/network.c.o
[  9%] Building C object CMakeFiles/websockets.dir/lib/core-net/vhost.c.o
[ 10%] Building C object CMakeFiles/websockets.dir/lib/core-net/pollfd.c.o
[ 11%] Building C object CMakeFiles/websockets.dir/lib/core-net/service.c.o
[ 12%] Building C object CMakeFiles/websockets.dir/lib/core-net/stats.c.o
[ 12%] Building C object CMakeFiles/websockets.dir/lib/core-net/wsi.c.o
[ 13%] Building C object CMakeFiles/websockets.dir/lib/core-net/wsi-timeout.c.o
[ 14%] Building C object CMakeFiles/websockets.dir/lib/core-net/adopt.c.o
[ 15%] Building C object CMakeFiles/websockets.dir/lib/roles/pipe/ops-pipe.c.o
[ 15%] Building C object CMakeFiles/websockets.dir/lib/roles/http/header.c.o
[ 16%] Building C object CMakeFiles/websockets.dir/lib/roles/http/server/parsers.c.o
[ 17%] Building C object CMakeFiles/websockets.dir/lib/roles/h1/ops-h1.c.o
[ 18%] Building C object CMakeFiles/websockets.dir/lib/roles/ws/ops-ws.c.o
[ 18%] Building C object CMakeFiles/websockets.dir/lib/roles/ws/client-ws.c.o
[ 19%] Building C object CMakeFiles/websockets.dir/lib/roles/ws/client-parser-ws.c.o
[ 20%] Building C object CMakeFiles/websockets.dir/lib/roles/ws/server-ws.c.o
[ 21%] Building C object CMakeFiles/websockets.dir/lib/roles/raw-skt/ops-raw-skt.c.o
[ 21%] Building C object CMakeFiles/websockets.dir/lib/roles/raw-file/ops-raw-file.c.o
[ 22%] Building C object CMakeFiles/websockets.dir/lib/misc/lwsac/lwsac.c.o
[ 23%] Building C object CMakeFiles/websockets.dir/lib/misc/lwsac/cached-file.c.o
[ 24%] Building C object CMakeFiles/websockets.dir/lib/core-net/connect.c.o
[ 24%] Building C object CMakeFiles/websockets.dir/lib/core-net/client.c.o
[ 25%] Building C object CMakeFiles/websockets.dir/lib/roles/http/client/client.c.o
[ 26%] Building C object CMakeFiles/websockets.dir/lib/roles/http/client/client-handshake.c.o
[ 27%] Building C object CMakeFiles/websockets.dir/lib/core-net/server.c.o
[ 27%] Building C object CMakeFiles/websockets.dir/lib/roles/listen/ops-listen.c.o
[ 28%] Building C object CMakeFiles/websockets.dir/lib/tls/tls.c.o
[ 29%] Building C object CMakeFiles/websockets.dir/lib/tls/tls-network.c.o
[ 30%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/tls.c.o
[ 30%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/x509.c.o
[ 31%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/ssl.c.o
[ 32%] Building C object CMakeFiles/websockets.dir/lib/tls/tls-server.c.o
[ 33%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/openssl-server.c.o
[ 33%] Building C object CMakeFiles/websockets.dir/lib/tls/tls-client.c.o
[ 34%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/openssl-client.c.o
[ 35%] Building C object CMakeFiles/websockets.dir/lib/misc/sha-1.c.o
[ 36%] Building C object CMakeFiles/websockets.dir/lib/roles/h2/http2.c.o
[ 36%] Building C object CMakeFiles/websockets.dir/lib/roles/h2/hpack.c.o
[ 37%] Building C object CMakeFiles/websockets.dir/lib/roles/h2/ops-h2.c.o
[ 38%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-caps.c.o
[ 39%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-file.c.o
[ 39%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-misc.c.o
[ 40%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-init.c.o
[ 41%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-pipe.c.o
[ 42%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-service.c.o
[ 42%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-sockets.c.o
[ 43%] Building C object CMakeFiles/websockets.dir/lib/plat/unix/unix-fds.c.o
[ 44%] Building C object CMakeFiles/websockets.dir/lib/roles/http/server/server.c.o
[ 45%] Building C object CMakeFiles/websockets.dir/lib/roles/http/server/lws-spa.c.o
[ 45%] Building C object CMakeFiles/websockets.dir/lib/event-libs/poll/poll.c.o
[ 46%] Building C object CMakeFiles/websockets.dir/lib/misc/lejp.c.o
[ 47%] Building C object CMakeFiles/websockets.dir/lib/roles/http/server/lejp-conf.c.o
[ 47%] Linking C static library lib/libwebsockets.a
[ 47%] Built target websockets
Scanning dependencies of target test-server-extpoll
[ 48%] Building C object CMakeFiles/test-server-extpoll.dir/test-apps/test-server.c.o
[ 48%] Linking C executable bin/libwebsockets-test-server-extpoll
[ 48%] Built target test-server-extpoll
Scanning dependencies of target test-server
[ 49%] Building C object CMakeFiles/test-server.dir/test-apps/test-server.c.o
[ 50%] Linking C executable bin/libwebsockets-test-server
[ 50%] Built target test-server
Scanning dependencies of target websockets_shared
[ 51%] Building C object CMakeFiles/websockets_shared.dir/lib/core/alloc.c.o
[ 52%] Building C object CMakeFiles/websockets_shared.dir/lib/core/context.c.o
[ 53%] Building C object CMakeFiles/websockets_shared.dir/lib/core/libwebsockets.c.o
[ 53%] Building C object CMakeFiles/websockets_shared.dir/lib/core/logs.c.o
[ 54%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/base64-decode.c.o
[ 55%] Building C object CMakeFiles/websockets_shared.dir/lib/core/vfs.c.o
[ 56%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/lws-ring.c.o
[ 56%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/dummy-callback.c.o
[ 57%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/output.c.o
[ 58%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/close.c.o
[ 59%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/network.c.o
[ 59%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/vhost.c.o
[ 60%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/pollfd.c.o
[ 61%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/service.c.o
[ 62%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/stats.c.o
[ 62%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/wsi.c.o
[ 63%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/wsi-timeout.c.o
[ 64%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/adopt.c.o
[ 65%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/pipe/ops-pipe.c.o
[ 65%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/header.c.o
[ 66%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/server/parsers.c.o
[ 67%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/h1/ops-h1.c.o
[ 68%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/ws/ops-ws.c.o
[ 68%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/ws/client-ws.c.o
[ 69%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/ws/client-parser-ws.c.o
[ 70%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/ws/server-ws.c.o
[ 71%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/raw-skt/ops-raw-skt.c.o
[ 71%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/raw-file/ops-raw-file.c.o
[ 72%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/lwsac/lwsac.c.o
[ 73%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/lwsac/cached-file.c.o
[ 74%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/connect.c.o
[ 74%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/client.c.o
[ 75%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/client/client.c.o
[ 76%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/client/client-handshake.c.o
[ 77%] Building C object CMakeFiles/websockets_shared.dir/lib/core-net/server.c.o
[ 77%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/listen/ops-listen.c.o
[ 78%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/tls.c.o
[ 79%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/tls-network.c.o
[ 80%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/tls.c.o
[ 80%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/x509.c.o
[ 81%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/ssl.c.o
[ 82%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/tls-server.c.o
[ 83%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/openssl-server.c.o
[ 83%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/tls-client.c.o
[ 84%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/openssl-client.c.o
[ 85%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/sha-1.c.o
[ 86%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/h2/http2.c.o
[ 86%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/h2/hpack.c.o
[ 87%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/h2/ops-h2.c.o
[ 88%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-caps.c.o
[ 89%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-file.c.o
[ 89%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-misc.c.o
[ 90%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-init.c.o
[ 91%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-pipe.c.o
[ 92%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-service.c.o
[ 92%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-sockets.c.o
[ 93%] Building C object CMakeFiles/websockets_shared.dir/lib/plat/unix/unix-fds.c.o
[ 94%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/server/server.c.o
[ 95%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/server/lws-spa.c.o
[ 95%] Building C object CMakeFiles/websockets_shared.dir/lib/event-libs/poll/poll.c.o
[ 96%] Building C object CMakeFiles/websockets_shared.dir/lib/misc/lejp.c.o
[ 97%] Building C object CMakeFiles/websockets_shared.dir/lib/roles/http/server/lejp-conf.c.o
[ 98%] Linking C shared library lib/libwebsockets.so
[ 98%] Built target websockets_shared
Scanning dependencies of target test-lejp
[ 99%] Building C object CMakeFiles/test-lejp.dir/test-apps/test-lejp.c.o
[ 99%] Linking C executable bin/libwebsockets-test-lejp
[ 99%] Built target test-lejp
Scanning dependencies of target test-client
[ 99%] Building C object CMakeFiles/test-client.dir/test-apps/test-client.c.o
[100%] Linking C executable bin/libwebsockets-test-client
[100%] Built target test-client

2.5 Installation

Installation command as follows (Of particular note in front of sudo , or installation error occurs):

sudo make install

The results are as follows:

cgs@ubuntu:~/libwebsockets/build$ sudo make install
[sudo] password for cgs: 
[ 47%] Built target websockets
[ 48%] Built target test-server-extpoll
[ 50%] Built target test-server
[ 98%] Built target websockets_shared
[ 99%] Built target test-lejp
[100%] Built target test-client
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/pkgconfig/libwebsockets.pc
-- Installing: /usr/local/lib/pkgconfig/libwebsockets_static.pc
-- Installing: /usr/local/include/libwebsockets
-- Installing: /usr/local/include/libwebsockets/lws-dbus.h
-- Installing: /usr/local/include/libwebsockets/lws-stats.h
-- Installing: /usr/local/include/libwebsockets/lws-ws-state.h
-- Installing: /usr/local/include/libwebsockets/lws-genhash.h
-- Installing: /usr/local/include/libwebsockets/lws-protocols-plugins.h
-- Installing: /usr/local/include/libwebsockets/lws-writeable.h
-- Installing: /usr/local/include/libwebsockets/lws-fts.h
-- Installing: /usr/local/include/libwebsockets/lws-ws-close.h
-- Installing: /usr/local/include/libwebsockets/lws-jwk.h
-- Installing: /usr/local/include/libwebsockets/lws-genrsa.h
-- Installing: /usr/local/include/libwebsockets/lws-genec.h
-- Installing: /usr/local/include/libwebsockets/lws-context-vhost.h
-- Installing: /usr/local/include/libwebsockets/lws-service.h
-- Installing: /usr/local/include/libwebsockets/lws-lwsac.h
-- Installing: /usr/local/include/libwebsockets/lws-client.h
-- Installing: /usr/local/include/libwebsockets/lws-cgi.h
-- Installing: /usr/local/include/libwebsockets/lws-callbacks.h
-- Installing: /usr/local/include/libwebsockets/lws-plugin-generic-sessions.h
-- Installing: /usr/local/include/libwebsockets/lws-jose.h
-- Installing: /usr/local/include/libwebsockets/lws-diskcache.h
-- Installing: /usr/local/include/libwebsockets/lws-genaes.h
-- Installing: /usr/local/include/libwebsockets/lws-vfs.h
-- Installing: /usr/local/include/libwebsockets/lws-network-helper.h
-- Installing: /usr/local/include/libwebsockets/lws-esp32.h
-- Installing: /usr/local/include/libwebsockets/lws-adopt.h
-- Installing: /usr/local/include/libwebsockets/lws-spa.h
-- Installing: /usr/local/include/libwebsockets/lws-lejp.h
-- Installing: /usr/local/include/libwebsockets/lws-gencrypto.h
-- Installing: /usr/local/include/libwebsockets/lws-purify.h
-- Installing: /usr/local/include/libwebsockets/lws-timeout-timer.h
-- Installing: /usr/local/include/libwebsockets/lws-tokenize.h
-- Installing: /usr/local/include/libwebsockets/lws-misc.h
-- Installing: /usr/local/include/libwebsockets/lws-logs.h
-- Installing: /usr/local/include/libwebsockets/lws-jwe.h
-- Installing: /usr/local/include/libwebsockets/lws-ws-ext.h
-- Installing: /usr/local/include/libwebsockets/lws-http.h
-- Installing: /usr/local/include/libwebsockets/lws-sha1-base64.h
-- Installing: /usr/local/include/libwebsockets/lws-threadpool.h
-- Installing: /usr/local/include/libwebsockets/lws-ring.h
-- Installing: /usr/local/include/libwebsockets/lws-x509.h
-- Installing: /usr/local/include/libwebsockets/lws-write.h
-- Installing: /usr/local/include/libwebsockets/lws-jws.h
-- Installing: /usr/local/lib/libwebsockets.a
-- Installing: /usr/local/include/libwebsockets.h
-- Installing: /usr/local/include/lws_config.h
-- Installing: /usr/local/include/lws-plugin-ssh.h
-- Installing: /usr/local/lib/libwebsockets.so.14
-- Installing: /usr/local/lib/libwebsockets.so
-- Up-to-date: /usr/local/include/libwebsockets.h
-- Up-to-date: /usr/local/include/lws_config.h
-- Up-to-date: /usr/local/include/lws-plugin-ssh.h
-- Installing: /usr/local/bin/libwebsockets-test-server
-- Installing: /usr/local/bin/libwebsockets-test-server-extpoll
-- Installing: /usr/local/bin/libwebsockets-test-lejp
-- Installing: /usr/local/bin/libwebsockets-test-client
-- Installing: /usr/local/share/libwebsockets-test-server/libwebsockets-test-server.key.pem
-- Installing: /usr/local/share/libwebsockets-test-server/libwebsockets-test-server.pem
-- Installing: /usr/local/share/libwebsockets-test-server/favicon.ico
-- Installing: /usr/local/share/libwebsockets-test-server/leaf.jpg
-- Installing: /usr/local/share/libwebsockets-test-server/candide.zip
-- Installing: /usr/local/share/libwebsockets-test-server/libwebsockets.org-logo.svg
-- Installing: /usr/local/share/libwebsockets-test-server/http2.png
-- Installing: /usr/local/share/libwebsockets-test-server/wss-over-h2.png
-- Installing: /usr/local/share/libwebsockets-test-server/lws-common.js
-- Installing: /usr/local/share/libwebsockets-test-server/test.html
-- Installing: /usr/local/share/libwebsockets-test-server/test.css
-- Installing: /usr/local/share/libwebsockets-test-server/test.js
-- Installing: /usr/local/share/libwebsockets-test-server/private/index.html
-- Installing: /usr/local/share/libwebsockets-test-server/lws-ssh-test-keys
-- Installing: /usr/local/share/libwebsockets-test-server/lws-ssh-test-keys.pub
-- Installing: /usr/local/lib/cmake/libwebsockets/LibwebsocketsConfig.cmake
-- Installing: /usr/local/lib/cmake/libwebsockets/LibwebsocketsConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/libwebsockets/LibwebsocketsTargets.cmake
-- Installing: /usr/local/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake

At this point, compiling the installation is complete.

3. Test

3.1 Test Tool

Libwebsockets test program can be used directly to provide direct tests:

  • libwebsockets-test-client
  • libwebsockets-test-server
  • libwebsockets-test-lejp
  • libwebsockets-test-server-extpoll

These test procedures compiled directory build / bin, as follows:

cgs@ubuntu:~/libwebsockets/build/bin$ ls
libwebsockets-test-client  libwebsockets-test-server
libwebsockets-test-lejp    libwebsockets-test-server-extpoll

3.2 server running

Run libwebsockets-test-serverthe following results:

cgs@ubuntu:~/libwebsockets/build/bin$ libwebsockets-test-server
[2019/02/19 17:24:56:3115] NOTICE: libwebsockets test server - license LGPL2.1+SLE
[2019/02/19 17:24:56:3115] NOTICE: (C) Copyright 2010-2018 Andy Green <[email protected]>
Using resource path "/usr/local/share/libwebsockets-test-server"

Can be seen by viewing port, libwebsockets-test-servertest program to open the server port to 7681 (of course, you can also specify the port and resources, not elaborate here)

cgs@ubuntu:~/libwebsockets/build/bin$ netstat -ntlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:7681            0.0.0.0:*               LISTEN      28252/libwebsockets
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -
tcp6       0      0 ::1:631                 :::*                    LISTEN      -

3.3 Run the client

The client runs the command format is as follows:

libwebsockets-test-client <server address> [--port=<p>] [--ssl] [-k] [-v <ver>] [-d <log bitfield>] [-l]

Run libwebsockets-test-clientthe following results:

cgs@ubuntu:~/libwebsockets/build/bin$ libwebsockets-test-client 127.0.0.1 --port=7681
[2019/02/19 17:28:36:0051] NOTICE: libwebsockets test client - license LGPL2.1+SLE
[2019/02/19 17:28:36:0052] NOTICE: (C) Copyright 2010-2018 Andy Green <[email protected]>
[2019/02/19 17:28:36:0052] NOTICE:  SSL disabled
[2019/02/19 17:28:36:0052] NOTICE:  Cert must validate correctly (use -s to allow selfsigned)
[2019/02/19 17:28:36:0052] NOTICE:  Requiring peer cert hostname matches
[2019/02/19 17:28:36:0370] NOTICE: created client ssl context for default
[2019/02/19 17:28:36:0371] NOTICE: using  mode (ws)
[2019/02/19 17:28:36:0371] NOTICE: dumb: connecting
[2019/02/19 17:28:36:0374] NOTICE: mirror: connecting
[2019/02/19 17:28:36:0381] NOTICE: mirror: LWS_CALLBACK_CLIENT_ESTABLISHED
[2019/02/19 17:28:36:0381] NOTICE: opened mirror connection with 24792 lifetime
[2019/02/19 17:28:52:7160] NOTICE: closing mirror session
[2019/02/19 17:28:52:7164] NOTICE: mirror: LWS_CALLBACK_CLOSED mirror_lifetime=0, rxb 0, rx_count 0
[2019/02/19 17:28:52:7169] NOTICE: mirror: connecting
[2019/02/19 17:28:52:7182] NOTICE: mirror: LWS_CALLBACK_CLIENT_ESTABLISHED
[2019/02/19 17:28:52:7184] NOTICE: opened mirror connection with 62611 lifetime
[2019/02/19 17:29:28:8881] NOTICE: closing mirror session
[2019/02/19 17:29:28:8886] NOTICE: mirror: LWS_CALLBACK_CLOSED mirror_lifetime=0, rxb 0, rx_count 0
[2019/02/19 17:29:28:8890] NOTICE: mirror: connecting
[2019/02/19 17:29:28:8902] NOTICE: mirror: LWS_CALLBACK_CLIENT_ESTABLISHED
[2019/02/19 17:29:28:8910] NOTICE: opened mirror connection with 35002 lifetime

3.4 websocket connection

In libwebsockets-test-servercan be seen in libwebsockets-test-clientthree times the connection information, as shown below:

cgs@ubuntu:~/libwebsockets/build/bin$ libwebsockets-test-server
[2019/02/19 17:24:56:3115] NOTICE: libwebsockets test server - license LGPL2.1+SLE
[2019/02/19 17:24:56:3115] NOTICE: (C) Copyright 2010-2018 Andy Green <[email protected]>
Using resource path "/usr/local/share/libwebsockets-test-server"
[2019/02/19 17:28:36:0378] NOTICE: Created new mi 0x1214ff0 ''
[2019/02/19 17:28:52:7177] NOTICE: Created new mi 0x1215010 ''
[2019/02/19 17:29:28:8897] NOTICE: Created new mi 0x1214fa0 ''

4. Frequently Asked Questions

Q: perform the installation command make install, appear the installation fails, the following error message:

cgs@ubuntu:~/libwebsockets/build$ make install
[ 47%] Built target websockets
[ 48%] Built target test-server-extpoll
[ 50%] Built target test-server
[ 98%] Built target websockets_shared
[ 99%] Built target test-lejp
[100%] Built target test-client
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/lib/pkgconfig/libwebsockets.pc
CMake Error at cmake_install.cmake:36 (file):
  file INSTALL cannot set permissions on
  "/usr/local/lib/pkgconfig/libwebsockets.pc"


Makefile:94: recipe for target 'install' failed
make: *** [install] Error 1

A: Because of the need to install /usr/bin, /usr/localcatalog copy files, etc., need su privileges, so it is necessary to adjust the install command sudo make install, a command that is added to the preceding sudo , su and follow the prompts to enter your password to install.

5. References

ubuntu compiled installation libwebsockets
https://blog.csdn.net/weixin_39510813/article/details/82527788

Guess you like

Origin blog.csdn.net/cgs1999/article/details/89704467