Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Build socket.io library for native SDKs

jianjunz edited this page Feb 22, 2023 · 10 revisions

OWT native SDK currently uses socket.io as the signaling protocol so it is depending on socket.io-client-cpp project.

P2P SDK is not implemented directly depending on socket.io, rather, the signaling channel implementation is provided by the sample application, so P2P SDK will not link to socket.io library, nor will it use socket.io headers. But since owt-server-p2p, which is the signaling server, is using socket.io, so your P2P application will need to link to socket.io library as well.

Conference SDK is implemented with signaling channel implementation embedded in the SDK. socket.io library binary will not be packed into OWT SDK binary, you will have to explicitly link to it in your application.

Build Instructions

Linux

The tested version of socket.io-client-cpp is documented in SDK guide. The latest version is likely to work, but we don't test all commits. cmake 2.8 and above is required for generation of build files for both Linux and Windows.

  git clone https://github.com/socketio/socket.io-client-cpp.git
  cd socket.io-client-cpp
  git checkout <specific version>  # Ignore this step if you want the latest version.
  git submodule update --init --recursive  # --init for initialization.
  mkdir build
  cd build
  cmake ../
  make

Windows

Build process of socket.io on windows is basically the same as Linux except the final step. On Windows a .sln file will be generated. depending on the VC runtime to be used for you application, you may specify VC runtime for all projects in this solution to either /MD, /MT, /MDd or /MTd. By default the OWT Windows SDK is built with /MT for release build, and /MTd for debug builds, so the socket.io solution will need to be configured accordingly.

Support TLS

The socket.io library is implemented with limited TLS support. You can build socket.io library with TLS support. Since Socket.IO TLS version depends on OpenSSL, while libwebrtc depends on OpenSSL or BoringSSL, if you statically link OWT SDK and Socket.IO lib, they must use the same version of OpenSSL. But if you dynamically link OWT and Socket.IO lib, they are not required to use the same version, or even the same implementation of SSL.

Windows

When running cmake, you will need to include path to openssl binary. For example,
cmake ../ -DOPENSSL_ROOT_DIR:STRING=c:\ssl_111k_64.
This requires ssl_111k_64 to contain a prebuilt binary of openssl library, where the build process is trying to access lib and include directory, as well as openssl.conf under that directory.

A sioclient_tls.vcxproj, besides the sioclient.vcxproj will be generated under sioclient.sln when OPENSSL_ROOT_DIR is specified and openssl headers can be found under specified OPENSSL_ROOT_DIR. After you build sioclient.sln, both sioclient.lib(without TLS support) and siocleint_tls.lib(with TLS support) will be created,

Special notes for openssl verison:

  • You should use the latest version of 1.1.1 or 3.0.x openssl libraries for linking to sioclient_tls.
  • If you link to TLS version of sioclient library, OWT SDK must be built with rtc_build_ssl=false in gn args. (passing ssl_root to build script). If you don't build OWT with openssl (instead using boringssl), you application will fail to link due to ssl symbol conflicts.

To build openssl from source by yourself:

  • Install and install Nasm from https://www.nasm.us, and add nasm.exe to your PATH. Create two folders under root of C:, for example, ssl_111n_bin & ssl_111n_dir.
  • Set VC env. Start from a command prompt and run(for example): "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
  • Go to openssl source directory, run perl Configure VC-WIN64A --prefix=c:\ssl_111n_bin --openssldir=c:\ssl_111n_dir no-shared
  • Run 'nmake && nmake install'. Pick up libssl.lib and libcyrpto.lib under c:\ssl_111n_bin directory.

Linux

You don't need to specify OPENSSL_ROOT_DIR when running cmake, but you need to make sure openssl library will be found by pkg-config --cflags --libs openssl before running cmake.

iOS

This external post has detailed steps to build OWT with socket.io cpp.

Clone this wiki locally