Lazarus

Programming => General => Topic started by: Ericktux on April 12, 2025, 03:57:42 pm

Title: Could not initialize OpenSSL library - ubuntu 24.10
Post by: Ericktux on April 12, 2025, 03:57:42 pm
Hi friend, I'm on Ubuntu 24.10 with Lazarus 3.8 and this code gives me the following error:
Code: Pascal  [Select][+][-]
  1. Could not initialize OpenSSL library
And this is the code I use:

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms,
  3.   opensslsockets, fphttpclient,
  4.   process, fpjson, jsonparser,
  5.   Controls, Graphics, Dialogs, StdCtrls;  
  6. ...
  7.   private
  8.     function ObtenerUltimaVersionGitHub: string;
  9. ...
  10. function TForm1.ObtenerUltimaVersionGitHub: string;
  11. var
  12.   HttpClient: TFPHTTPClient;
  13.   JSONData: TJSONData;
  14.   JSONStr: string;
  15. begin
  16.   Result := '';
  17.   HttpClient := TFPHTTPClient.Create(nil);
  18.   try
  19.     HttpClient.AddHeader('User-Agent', 'Mozilla/5.0');
  20.     JSONStr := HttpClient.Get('https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest');
  21.     JSONData := GetJSON(JSONStr);
  22.     Result := JSONData.FindPath('tag_name').AsString;
  23.   except
  24.     on E: Exception do
  25.       Memo1.Lines.Add('Error al consultar GitHub: ' + E.Message);
  26.   end;
  27.   HttpClient.Free;
  28. end;

When I type this into the terminal:
Code: Pascal  [Select][+][-]
  1. openssl version

I get the following:
Code: Pascal  [Select][+][-]
  1. OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)

Please help  :(

PD: It works fine on Windows
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: Fred vS on April 12, 2025, 04:31:02 pm
Hello.

Try this:

Code: Pascal  [Select][+][-]
  1. ...
  2. uses
  3.  openssl, { This implements the procedure InitSSLInterface }
  4. ...
  5.  
  6. function TForm1.ObtenerUltimaVersionGitHub: string;
  7. var
  8.   HttpClient: TFPHTTPClient;
  9.   JSONData: TJSONData;
  10.   JSONStr: string;
  11. begin
  12.   Result := '';
  13.   InitSSLInterface;  // Add this
  14.   HttpClient := TFPHTTPClient.Create(nil);
  15.   try
  16.     HttpClient.AddHeader('User-Agent', 'Mozilla/5.0');
  17.     JSONStr := HttpClient.Get('https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest');
  18.     JSONData := GetJSON(JSONStr);
  19.     Result := JSONData.FindPath('tag_name').AsString;
  20.   except
  21.     on E: Exception do
  22.       Memo1.Lines.Add('Error al consultar GitHub: ' + E.Message);
  23.   end;
  24.   HttpClient.Free;
  25. end;
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: Ericktux on April 12, 2025, 04:53:53 pm
Thank you very much my friend for your help, I just tried it but the same error persists.  :(
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: TRon on April 12, 2025, 05:25:02 pm
Thank you very much my friend for your help, I just tried it but the same error persists.  :(
Good news: code works  :) bad news: needs manual labour to find error.

Please start app from a terminal window and see if it produces a more meaningful error. If it does please paste error here. If that does not produce a useful error message then open a terminal and use strace <appname>. to find out what exact library is missing (I am assuming that your problem is related to  a missing library).

Note that it might be that trunk fpc is required for newer ssl libraries or use the dev package solution (meaning install all the relevant dev packages that link to the correct ssl libraries).
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: Ericktux on April 12, 2025, 09:17:07 pm
Hello friend, thank you very much for your help. The command "strace ./project1" gives me too much information. I used the following command (IA):
Code: Pascal  [Select][+][-]
  1. strace -e trace=openat ./project1 2>&1 | grep -i ssl

and it returned the following:
Code: Pascal  [Select][+][-]
  1. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  2. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  3. openat(AT_FDCWD, "/lib/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  4. openat(AT_FDCWD, "/usr/lib/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  5. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  6. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  7. openat(AT_FDCWD, "/lib/libssl.so.1.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  8. openat(AT_FDCWD, "/usr/lib/libssl.so.1.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  9. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.11", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  10. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.11", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  11. openat(AT_FDCWD, "/lib/libssl.so.11", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  12. openat(AT_FDCWD, "/usr/lib/libssl.so.11", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  13. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.10", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  14. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.10", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  15. openat(AT_FDCWD, "/lib/libssl.so.10", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  16. openat(AT_FDCWD, "/usr/lib/libssl.so.10", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  17. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  18. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  19. openat(AT_FDCWD, "/lib/libssl.so.1.0.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  20. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  21. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  22. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  23. openat(AT_FDCWD, "/lib/libssl.so.1.0.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  24. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  25. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  26. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  27. openat(AT_FDCWD, "/lib/libssl.so.1.0.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  28. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  29. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  30. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  31. openat(AT_FDCWD, "/lib/libssl.so.1.0.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  32. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  33. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  34. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  35. openat(AT_FDCWD, "/lib/libssl.so.1.0.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  36. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  37. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  38. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  39. openat(AT_FDCWD, "/lib/libssl.so.1.0.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  40. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  41. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  42. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  43. openat(AT_FDCWD, "/lib/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  44. openat(AT_FDCWD, "/usr/lib/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  45. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.8", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  46. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.8", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  47. openat(AT_FDCWD, "/lib/libssl.so.0.9.8", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  48. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.8", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  49. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  50. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  51. openat(AT_FDCWD, "/lib/libssl.so.0.9.7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  52. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  53. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  54. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  55. openat(AT_FDCWD, "/lib/libssl.so.0.9.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  56. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  57. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  58. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  59. openat(AT_FDCWD, "/lib/libssl.so.0.9.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  60. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  61. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  62. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  63. openat(AT_FDCWD, "/lib/libssl.so.0.9.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  64. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  65. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  66. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  67. openat(AT_FDCWD, "/lib/libssl.so.0.9.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  68. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  69. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  70. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  71. openat(AT_FDCWD, "/lib/libssl.so.0.9.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  72. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  73. openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libssl.so.0.9.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  74. openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libssl.so.0.9.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  75. openat(AT_FDCWD, "/lib/libssl.so.0.9.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)
  76. openat(AT_FDCWD, "/usr/lib/libssl.so.0.9.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No existe el archivo o el directorio)

Apparently, Lazarus Pascal works with OpenSSL 1.1, but Ubuntu 24.10 works with OpenSSL 3.3.1.
What do you recommend, friends?  :(
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: TRon on April 12, 2025, 09:37:21 pm
Hello friend, thank you very much for your help. The command "strace ./project1" gives me too much information. I used the following command (IA):
Yes, I probably should have mentioned that the output can be shortend with only checking open. Good that you were able to figure that out on your own.

Quote
What do you recommend, friends?  :(
In theory, it could be solved with installing the dev package. Have you installed package libssl-dev ? When installed there will be softlinks installed in the system that point to the correct library (while the application still uses the old name).

If that also fails, and in case this version is already supported, then using main/trunk FPC compiler is the only other option (*).

(*() with the exception of downgrading OS and/or libssl which are both not advisable to do.
Title: Re: Could not initialize OpenSSL library - ubuntu 24.10
Post by: Ericktux on April 13, 2025, 06:26:52 am
Thank you very much my friend, installing "libssl-dev" solved the problem.
Code: Pascal  [Select][+][-]
  1. sudo apt install libssl-dev

Greetings and thanks  :)
TinyPortal © 2005-2018