1

I'm trying to compile and use static WebRTC against OpenSSL 1.1.1 on Windows in a Visual Studio project, here's my gn line :

gn gen ./intermediate --args="target_cpu=\"x64\" use_rtti=false is_debug=true symbol_level=2 enable_iterator_debugging=true rtc_build_tools=false rtc_build_examples=false rtc_include_tests=false enable_precompiled_headers=false use_cxx11=false use_custom_libcxx=false use_custom_libcxx_for_host=false rtc_build_ssl=false rtc_ssl_root=\"C:/libs/OpenSSL/include:\=\\%\" rtc_build_json=false rtc_jsoncpp_root=\"C:/libs/JsonCpp/include:\=\\%\" is_clang=false is_component_build=false use_lld=false dcheck_is_configurable=true"

The compilation is OK, but in my Visual Studio 2019 project I've got these 1156 errors at the linker step :

1 - libssl.lib(ssl_lib.obj) : error LNK2005: SSL_CTX_check_private_key already defined in webrtc.lib(ssl_lib.obj)
2 - libssl.lib(ssl_lib.obj) : error LNK2005: SSL_CTX_clear_options already defined in webrtc.lib(ssl_lib.obj)
3 - libssl.lib(ssl_lib.obj) : error LNK2005: SSL_CTX_free already defined in webrtc.lib(ssl_lib.obj)
4 - libssl.lib(ssl_lib.obj) : error LNK2005: SSL_CTX_get0_certificate already defined in webrtc.lib(ssl_x509.obj)
...
1154 - libcrypto.lib(p12_asn.obj) : error LNK2005: d2i_PKCS12 already defined in webrtc.lib(pkcs8_x509.obj)
1155 - libcrypto.lib(p12_asn.obj) : error LNK2005: i2d_PKCS12 already defined in webrtc.lib(pkcs8_x509.obj)
1156 - libcrypto.lib(asn1_par.obj) : error LNK2005: ASN1_tag2str already defined in webrtc.lib(asn1_par.obj)

I understood that this appended because libssl.lib and libcrypto.lib are already aggregated in webrtc.lib. But in this project I also use Curl and LibWebSocket that also depend on the same OpenSSL static libs, and when I try to remove libssl.lib and crypto.lib from the linker input this fail with 67 unresolved symbols:

1 - websockets_static.lib(openssl-server.obj) : error LNK2001: unresolved external symbol SSL_ctrl
2 - webrtc.lib(openssl_adapter.obj) : error LNK2001: unresolved external symbol SSL_ctrl
...
66 - libcurl.lib(openssl.obj) : error LNK2019: unresolved external symbol ENGINE_set_default referenced in function x509_name_oneline
67 - websockets_static.lib(openssl-server.obj) : error LNK2019: unresolved external symbol SSL_CTX_callback_ctrl referenced in function lws_tls_server_vhost_backend_init

So my feeling is that only some part of libssl.lib and crypto.lib that are needed by webrtc.lib are aggregated during the compilation of webrtc.lib

My question is : how to avoid sub-library aggregation during webrtc compilation ? The option rtc_build_ssl=false seems to have no effect ... What is the option and where can I pass it ?

SamT
  • 528
  • 4
  • 14
  • For instance, after a deep search in WebRTC source code, the first symbol is only defined here : C:\cpplibs\Sources\WebRTC\m85\src\third_party\boringssl\src\ssl\ssl_lib.cc Line 1716: int SSL_CTX_check_private_key(const SSL_CTX *ctx) { .... } So this is really a problem with rtc_build_ssl=false, it doesn't seems to work, or something else block its effect as nothing in third_party/boringssl folder should be compiled... – SamT Aug 07 '20 at 09:30

2 Answers2

1

After facing the same problems as you I switched to the latest OpenSSL version 3.0.0-beta2-dev and then I didn't see all these "already defined" any more.

That means I could compile and link without errors but unfortunately it doesn't work and stops in OpenSSLDigest::GetDigestEVP(). So WebRTC doesn't seem to support OpenSSL 3.0.0. Did you meanwhile manage to get it compiled, linked and running with OpenSSL 1.1.1?

Obsidian
  • 3,719
  • 8
  • 17
  • 30
0

I Faced the same problme. Have you solved it.

gn gen out/Release --args="is_debug=false is_component_build=false rtc_include_tests=false use_custom_libcxx=false symbol_level=0 rtc_enable_symbol_export=false use_rtti=true rtc_build_examples=false rtc_build_ssl=false rtc_ssl_root=\"C:\OpenSSL-Win64\include""

I use rtc_build_ssl = false . But I found that ,boringssl still compiled and linked

Kaveh
  • 1,158
  • 6
  • 16