mediasoup-broadcaster-demo - compile error on Mac - can't use built in openssl lib

Im trying to compile the lib on MacOS Catalina.

In the last step: make -C build
The process fails with the message:

[ 65%] Linking C shared library ../../../../lib/libcurl.dylib ld: cannot link directly with dylib/framework, your binary is not an allowed client of /usr/lib/libcrypto.dylib for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [lib/libcurl.dylib] Error 1 make[1]: *** [cpr/opt/curl/lib/CMakeFiles/libcurl.dir/all] Error 2 make: *** [all] Error 2
Note: I have set the PATH_TO_OPENSSL_HEADERS in the command to /usr/local/opt/openssl/include as instructed in the README

Any solutions to this?

This looks like a Catalina specific problem. I’m running Mojave myself so I can test it right now.

Please look for this error out there, there are many people who already faced it. Ie just searching in google:

1 Like

I think I found a working solution here. A lot of other solutions out there recommend doing crazy things like removing your system library files and symlinking from the homebrew install. That is hacky as hell and I needed a reproducible solution.

After digging around in CMake’s FinOpenSSL.cmake file a bit it appears that even when you specify -DOPENSSL_ROOT_DIR and point it to your homebrew openssl install, it doesn’t find the crypto lib in the same path. After more digging I found you can override this library path from the command line using -DOPENSSL_CRYPTO_LIBRARY.

So my build command looks like this:

cmake . -Bbuild \                                                                                ─╯
-DLIBWEBRTC_INCLUDE_PATH:PATH=/Users/alexciarlillo/code/googlesource/webrtc-checkout/src \
-DLIBWEBRTC_BINARY_PATH:PATH=/Users/alexciarlillo/code/googlesource/webrtc-checkout/src/out/m84/obj \
-DCMAKE_USE_OPENSSL=ON \
-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl@1.1/1.1.1h \
-DOPENSSL_CRYPTO_LIBRARY=/usr/local/Cellar/openssl@1.1/1.1.1h/lib/libcrypto.1.1.dylib

Of course replace with the paths to your libwebrtc stuff and corresponding installed openssl version.

Hope that helps someone!

1 Like

Thanks @alexciarlillo! mediasoup-broadcaster-demo README.md has been updated with this info.