winddriver / Delphi-Cross-Socket

Delphi cross platform socket library
GNU Lesser General Public License v3.0
408 stars 156 forks source link

Build without SSL support #142

Open mbnoimi opened 4 months ago

mbnoimi commented 4 months ago

Can I build DCS without SSL support?

Currently I'm unable to build because if this error:

[DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\23.0\CatalogRepository\AndroidNDK-21-23.0.51961.7529\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lcrypto
  C:\Users\Public\Documents\Embarcadero\Studio\23.0\CatalogRepository\AndroidNDK-21-23.0.51961.7529\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lssl
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::OPENSSL_init_ssl(unsigned long long, void*): error: undefined reference to 'OPENSSL_init_ssl'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::TLS_method(): error: undefined reference to 'TLS_method'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_new(void*): error: undefined reference to 'SSL_CTX_new'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_free(void*): error: undefined reference to 'SSL_CTX_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_ctrl(void*, int, int, char*): error: undefined reference to 'SSL_CTX_ctrl'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_set_verify(void*, int, int (*)(int, void*)): error: undefined reference to 'SSL_CTX_set_verify'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_set_cipher_list(void*, char*): error: undefined reference to 'SSL_CTX_set_cipher_list'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_use_PrivateKey(void*, void*): error: undefined reference to 'SSL_CTX_use_PrivateKey'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_use_certificate(void*, void*): error: undefined reference to 'SSL_CTX_use_certificate'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_check_private_key(void*): error: undefined reference to 'SSL_CTX_check_private_key'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_new(void*): error: undefined reference to 'SSL_new'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_set_bio(void*, void*, void*): error: undefined reference to 'SSL_set_bio'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_get_error(void*, int): error: undefined reference to 'SSL_get_error'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_shutdown(void*): error: undefined reference to 'SSL_shutdown'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_free(void*): error: undefined reference to 'SSL_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_set_connect_state(void*): error: undefined reference to 'SSL_set_connect_state'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_set_accept_state(void*): error: undefined reference to 'SSL_set_accept_state'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_do_handshake(void*): error: undefined reference to 'SSL_do_handshake'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_read(void*, void*, int): error: undefined reference to 'SSL_read'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_write(void*, void const*, int): error: undefined reference to 'SSL_write'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_is_init_finished(void*): error: undefined reference to 'SSL_is_init_finished'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::SSL_CTX_get_cert_store(void const*): error: undefined reference to 'SSL_CTX_get_cert_store'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::OpenSSL_version_num(): error: undefined reference to 'OpenSSL_version_num'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::OPENSSL_init_crypto(unsigned long long, void*): error: undefined reference to 'OPENSSL_init_crypto'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::OPENSSL_cleanup(): error: undefined reference to 'OPENSSL_cleanup'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::ERR_error_string_n(unsigned int, char*, unsigned int): error: undefined reference to 'ERR_error_string_n'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::EVP_PKEY_free(void*): error: undefined reference to 'EVP_PKEY_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_new(void*): error: undefined reference to 'BIO_new'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_ctrl(void*, int, int, void*): error: undefined reference to 'BIO_ctrl'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_new_mem_buf(void*, int): error: undefined reference to 'BIO_new_mem_buf'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_free(void*): error: undefined reference to 'BIO_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_s_mem(): error: undefined reference to 'BIO_s_mem'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_read(void*, void*, int): error: undefined reference to 'BIO_read'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::BIO_write(void*, void*, int): error: undefined reference to 'BIO_write'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::EC_KEY_new_by_curve_name(int): error: undefined reference to 'EC_KEY_new_by_curve_name'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::EC_KEY_free(void*): error: undefined reference to 'EC_KEY_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::X509_free(void*): error: undefined reference to 'X509_free'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::X509_STORE_add_cert(void*, void*): error: undefined reference to 'X509_STORE_add_cert'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::PEM_read_bio_X509(void*, void**, int (*)(void*, int, int, void*), void*): error: undefined reference to 'PEM_read_bio_X509'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::PEM_read_bio_X509_AUX(void*, void**, int (*)(void*, int, int, void*), void*): error: undefined reference to 'PEM_read_bio_X509_AUX'
  Z:\Projects\WebSocket Example\Client\bin\Android\Debug\Net.OpenSSL.o:Net.OpenSSL:function Net::Openssl::PEM_read_bio_PrivateKey(void*, void**, int (*)(void*, int, int, void*), void*): error: undefined reference to 'PEM_read_bio_PrivateKey'
[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)
Failed

If I can't build without SSL support. How can I add the missing OpenSSL libs? This is my full project: https://github.com/mbnoimi/websocket-client

mbnoimi commented 4 months ago

I added OpenSSL libs to be able to build DCS as following:

  1. Cloned OpenSSL binaries from PurpleI2P
  2. Added libs/include paths into Project -> Building -> Delphi Compiler -> Search path (armeabi-v7a for Android 32-bit and arm64-v8a for Android 64-bit):

image

image

After adding OpenSSL my simple app keeps crashing on startup (only sees splash screen). I tried many other OpenSSL binaries but still get same result.

I really don't need wss I just want to run ws protocol so SSL doesn't matter for me but I'm still unable to build DCS without OpenSSL libs.

May I get some help please (I prepared my project for simple/easy testing)?