robotconscience/ofxLibwebsockets

Problem with ubuntu 18 and workaround

gorkacortazar opened this issue · 2 comments

While porting our apps to Ubuntu 18 this week, we discovered problems (again is a mismatch of SSL versions against the compiled version).

While we can do a pull request, the changes that we did make the addon not compatible with ubuntu 16 or other linux versions. This recipe may also work in RPI or other linux flavors.

  • The problem: Ubuntu 18 has a more recent version of the SSL library, the API is different, and definitely that version of libwebsockets does not support it.
  • There are two different methods deprecated is OpenSSL that makes the compilation from the ligwebsockets git fail
  • Ubuntu 18 uses a different version of GCC (7) than 16.04 (GCC 5). This will require the library to be recompiled.

We solved it with these steps:

  1. Clone libwebsockets source: https://github.com/warmcat/libwebsockets.git
  2. Checkout the tag v1.4-chrome43-firefox-36
  3. open the file libs/ssl.c
  4. search the calls to ERR_remove_thread_state (there are two instances)
  5. Replace the full #if block with this code:
#if (OPENSSL_VERSION_NUMBER <  0x10100000)
    #if (OPENSSL_VERSION_NUMBER <= 0x1000106f) || defined(USE_WOLFSSL)
       ERR_remove_state(0);
   #else
       #if OPENSSL_VERSION_NUMBER >= 0x1010005f && !defined(LIBRESSL_VERSION_NUMBER) && defined(OPENSSL_IS_BORINGSSL)
            ERR_remove_thread_state();
        #else
            ERR_remove_thread_state(NULL);
        #endif
    #endif
#endif
  1. Create a folder build and enter the folder
  2. Create the make files with cmake -DLIB_SUFFIX=64 ..
  3. Build with make
  4. Copy the file in the build/lib/libwebsockets.a and replace the one in the addon
  5. in the add on rules add this under linux64 (addon_config.mk), to include the OpenSSL in the linking process, as openframeworks 0.10 uses the library installed int he system.
linux64:
	# binary libraries, these will be usually parsed from the file system but some 
	# libraries need to passed to the linker in a specific order 
	#nothing yet
	ADDON_LDFLAGS += -lssl
	ADDON_LDFLAGS += -lcrypto

Thank you very much, you're great. Your post saved me a week of work. I managed to connect and build this with OF 0.11.0 on linux mint 19.3, and it works!