Congratulations to our 2022 Qt Champions!

Link OpenSSL to webassembly works in 5.13.2 but not in 5.15.2 ?

  • Hi,

    For context, I am trying to make a minimalist webassembly application using OpenSSL encryption for a proof of concept, just to be sure it's possible.

    I have correctly handled this for an Qt 5.13.2 application like this :

    Build OpenSSL 1.1.1k on a Linux VM

    1. Install Emscripten 1.38.30
    ./emsdk install sdk-fastcomp-1.38.30-64bit
    ./emsdk activate sdk-fastcomp-1.38.30-64bit
    source ./
    1. Compile OpenSSL
    emmake ./config -no-asm
    emmake make

    Build Qt app (on Windows)

    1. Link OpenSSL in the .pro
    INCLUDEPATH += "C:/***/openssl-wasm/include"
    LIBS += "C:/***/openssl-wasm/libcrypto.a" "C:/***/openssl-wasm/libssl.a"
    1. Compile in Webassembly
    mkdir build-wasm
    cd build-wasm
    emsdk activate sdk-fastcomp-1.38.30-64bit
    C:\Qt\5.13.2\wasm_32\bin\qmake.exe ..

    After these steps, I have a working webassembly app that can use OpenSSL encryption.

    Problem comes when I tried to compile the same minimalist app but for Qt 5.15.2 :
    -I compiled OpenSSL with emsdk-1.39.7 instead.
    -Static link OpenSSL (as before in the .pro)
    -Compiled in webassembly with emscripten 1.39.7 (make with mingw 810_64)
    But the compilation give me this error :

    I also tried with emscripten 1.39.8, but with the same error.

    I guess it should be possible to link OpenSSL with Qt 5.15.2. Am I missing something here ? Any hints would be really helpful and appreciated.

    Thanks ;)

  • Hi,
    I haven't tested ssl support for a while now. Off the top of my head, you my need to play with build arguments of openssl. It looks like openssl might be using pthreads, which Qt WebAssembly does not use by default.

    What version of openssl are you using?

    In the meantime, if you could report this bug to Qt, that would be great!

  • @lorn-potter hi and thanks for you reply

    openssl might be using pthreads, which Qt WebAssembly does not use by default

    Does that mean that I should build qt from source and enable thread support with the "-feature-thread" flag ? As the binary packages do not support multithreading.

    I am trying to link OpenSSL 1.1.1k, but if you know and other known good version I am interested.

    From the OpenSSL wiki, I see the no-threads option, I'll try and let you know.

    I think I will search a bit deeper before submitting a bug.

  • Building OpenSSL with the no-threads option solve the problem in my case.

    I don't really search deeper what is the consequences of that build option but maybe it can help someone ;)