How to avoid sub-library aggregation during webrtc compilation on Windows?

697 views
Skip to first unread message

Samuel Tranchet

unread,
Aug 6, 2020, 6:37:59 AM8/6/20
to discuss-webrtc
Hi everybody,

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 ?

Thanks a lot for your help.

JD Arnold

unread,
Aug 7, 2020, 8:53:29 AM8/7/20
to discuss-webrtc
Yeah, I gave up trying to figure it out. I hand edited the BUILD.gn file and removed all mention of boringssl. This required adding the include path for our own openssl install as well for a few of them. Google is not very good at really caring about working with OpenSSL. Some releases it works but most it doesn't.

d͇̓j̣̘̉̕ ̭̮̿̚ṗ͓̪͡ȩ͖̽̓e̤͌t̲̟̃͡õ̦̖̉n̫̂n͓̭̓̕ }

unread,
Jun 17, 2021, 9:04:18 AM6/17/21
to discuss-webrtc
curious if there's been any resolution on this problem? I'm facing similar issue where webrtc M84 compiled with `rtc_build_ssl=false` flag still conflicts with libcurl version that is linked with the application.

libcurl_a.lib(x509_set.obj) : error LNK2005: X509_get0_extensions already defined in webrtc.lib(x509_set.obj)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_get0_notAfter already defined in webrtc.lib(x509_set.obj)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_get0_notBefore already defined in webrtc.lib(x509_set.obj)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_get0_tbs_sigalg already defined in webrtc.lib(x509_set.obj)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_get_X509_PUBKEY already defined in libcrypto.lib(libcrypto-1_1-x64.dll)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_getm_notAfter already defined in webrtc.lib(x509_set.obj)
libcurl_a.lib(x509_set.obj) : error LNK2005: X509_getm_notBefore already defined in webrtc.lib(x509_set.obj)
...

peks geshkov

unread,
Jun 18, 2021, 2:49:03 AM6/18/21
to discuss...@googlegroups.com

Hello,

I reported this problem long time ago and nothing happens. I am stuck in situation like this as well because my project depend from libssl and libcrypto but my linkage procedure is ok. My app crashes when hit some crypto functions in peer connection and data channel. Webrtc team use boringssl and some functions are refactored and using fipsmodule for some reasons. Then I create two tickets from https://bugs.chromium.org/p/webrtc/issues/detail?id=12641&q=&can=4 and https://bugs.chromium.org/p/webrtc/issues/detail?id=12767&q=&can=4. WEBRTC team have big problem with openssl library and this issues come alive from webrtc88 version!!!

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/976a1ea5-ac8d-4296-8256-8e04a3a07b32n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages