Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL static link #158

Open
gaoqiangz opened this issue Jun 10, 2022 · 2 comments
Open

OpenSSL static link #158

gaoqiangz opened this issue Jun 10, 2022 · 2 comments

Comments

@gaoqiangz
Copy link

gaoqiangz commented Jun 10, 2022

Enviroments:

OPENSSL_INCLUDE_DIR=C:\Program Files\OpenSSL-Win64\include
OPENSSL_LIB_DIR=C:\Program Files\OpenSSL-Win64\lib\VC\static
OPENSSL_LIBS=libcrypto64MT:libssl64MT
OPENSSL_STATIC=1

.cargo/config:

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

Link errors:

libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_ctrl already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_get_ex_data already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_load_verify_locations already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_new already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_alpn_protos already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_cipher_list already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_default_passwd_cb already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_default_passwd_cb_userdata already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_default_verify_paths already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_ex_data already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_msg_callback already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_psk_client_callback already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_security_level already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_CTX_set_verify already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_accept already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_connect already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_ctrl already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_SSL_CTX already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_cipher_list already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_current_cipher already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_error already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_peer_certificate already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_get_verify_result already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_new already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_pending already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_read already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_set_bio already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_set_fd already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_shutdown already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_lib.obj) : error LNK2005: SSL_write already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(mem.obj) : error LNK2005: CRYPTO_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_lib.obj) : error LNK2005: BIO_get_data already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_lib.obj) : error LNK2005: BIO_new already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_lib.obj) : error LNK2005: BIO_set_data already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_lib.obj) : error LNK2005: BIO_set_init already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_new already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_create already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_ctrl already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_destroy already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_puts already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_read already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(bio_meth.obj) : error LNK2005: BIO_meth_set_write already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(x509_lu.obj) : error LNK2005: X509_STORE_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(p12_asn.obj) : error LNK2005: PKCS12_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(rand_lib.obj) : error LNK2005: RAND_bytes already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(err.obj) : error LNK2005: ERR_clear_error already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(err.obj) : error LNK2005: ERR_get_error already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_sess.obj) : error LNK2005: SSL_CTX_set_info_callback already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_sess.obj) : error LNK2005: SSL_SESSION_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_sess.obj) : error LNK2005: SSL_get1_session already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_sess.obj) : error LNK2005: SSL_set_session already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_ciph.obj) : error LNK2005: SSL_CIPHER_get_name already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(methods.obj) : error LNK2005: TLS_client_method already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_rsa.obj) : error LNK2005: SSL_CTX_use_PrivateKey already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_rsa.obj) : error LNK2005: SSL_CTX_use_PrivateKey_file already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_rsa.obj) : error LNK2005: SSL_CTX_use_certificate_chain_file already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_stat.obj) : error LNK2005: SSL_alert_desc_string_long already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_stat.obj) : error LNK2005: SSL_alert_type_string_long already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ssl_stat.obj) : error LNK2005: SSL_state_string_long already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libssl-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(cversion.obj) : error LNK2005: OpenSSL_version already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(x_x509.obj) : error LNK2005: X509_free already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(v3_utl.obj) : error LNK2005: X509_check_host already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(v3_utl.obj) : error LNK2005: X509_check_ip_asc already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(ex_data.obj) : error LNK2005: CRYPTO_get_ex_new_index already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(init.obj) : error LNK2005: OPENSSL_init_crypto already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(err_prn.obj) : error LNK2005: ERR_print_errors_cb already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(sha1dgst.obj) : error LNK2005: SHA1_Final already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(sha1dgst.obj) : error LNK2005: SHA1_Init already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)
libopenssl_sys-928cbc1dc8421ac1.rlib(sha1dgst.obj) : error LNK2005: SHA1_Update already defined in libpaho_mqtt_sys-8790c56f3d8a7649.rlib(libcrypto-1_1-x64.dll)

Link configuration should be maintained by openssl-sys, otherwise there will be a symbol conflict,remove these code solved the problem:

https://github.com/eclipse/paho.mqtt.rust/blob/e9e4b804b56f2731af9c0ecf4712d5f5871c25ba/paho-mqtt-sys/build.rs#L314-L340

@fpagliughi
Copy link
Contributor

Thanks for bringing this up!

Unfortunately, when I tried removing this code from build.rs I got linker issues when building the examples. (I'm doing initial testing on Ubuntu 20.04 Linux). Any ideas about that?

@gaoqiangz
Copy link
Author

gaoqiangz commented Mar 14, 2023

I have created a PR for resolve this problem #200.
Please take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants