Last active
January 22, 2020 05:58
-
-
Save raiym/1e8bb17d70b631fe51b2b9c0ab6f7206 to your computer and use it in GitHub Desktop.
Build libwesocket library statically for Ubuntu 18.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt install wget | |
apt install gcc | |
apt install make | |
apt install cmake | |
WORKDIR=$(pwd .) | |
export WORKDIR | |
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz | |
tar -xzf OpenSSL_1_1_1d.tar.gz | |
cd openssl-OpenSSL_1_1_1d || exit | |
./config no-shared | |
make | |
cd "$WORKDIR" || exit | |
wget https://github.com/libuv/libuv/archive/v1.34.1.tar.gz | |
tar -xzf v1.34.1.tar.gz | |
cd libuv-1.34.1 || exit | |
mkdir -p out/cmake/ | |
cd out/cmake/ || exit | |
cmake ../.. -DBUILD_TESTING=ON -DCMAKE_C_FLAGS="-fpic" | |
cmake --build . | |
cd "$WORKDIR" || exit | |
wget https://github.com/madler/zlib/archive/v1.2.11.tar.gz | |
tar -xzf v1.2.11.tar.gz | |
cd zlib-1.2.11 || exit | |
./configure | |
cmake -DCMAKE_C_FLAGS="-fpic" | |
make | |
cd "$WORKDIR" || exit | |
wget https://github.com/warmcat/libwebsockets/archive/v3.2.2.tar.gz | |
tar -xzf v3.2.2.tar.gz | |
cd libwebsockets-3.2.2 || exit | |
rm -rf ./minimal-examples/http-server/minimal-http-server-eventlib-foreign/ | |
mkdir build | |
cd build || exit | |
cmake .. -DLWS_OPENSSL_INCLUDE_DIRS="$WORKDIR"/openssl-OpenSSL_1_1_1d/include -DLWS_OPENSSL_LIBRARIES="$WORKDIR/openssl-OpenSSL_1_1_1d/libssl.a;$WORKDIR/openssl-OpenSSL_1_1_1d/libcrypto.a" -DLWS_WITH_MINIMAL_EXAMPLES=1 -DLWS_WITH_LWSWS=1 -DLWS_WITH_HTTP2=0 -DLWS_WITH_CGI=1 -DLWS_WITHOUT_EXTENSIONS=0 -DLIBUV_INCLUDE_DIRS="$WORKDIR"/libuv-1.34.1/include -DLIBUV_LIBRARIES="$WORKDIR"/libuv-1.34.1/out/cmake/libuv_a.a -DZLIB_LIBRARY="$WORKDIR"/zlib-1.2.11/libz.a -DZLIB_INCLUDE_DIR="$WORKDIR"/zlib-1.2.11 -DCMAKE_C_FLAGS="-fpic" | |
make | |
# Now one can run libwebsocket echo server and save it for later use: located here "$WORKDIR"/libwebsockets-3.2.2/build/bin/lws-minimal-ws-server-echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment