Linking a custom version of openSSL lazarus / 32-Linux ---------------------------------------------------------------------- Grahame Grieve · 2023-05-21 11:55 I have a custom version of openSSL I need to link to. I'm using the fork of indy that's right for that verstion of openSSL. When I try to compile, I get this error: Warning: linker: /usr/bin/ld: cannot find -lcrypto-1_1: No such file or directory Warning: linker: /usr/bin/ld: cannot find -lssl-1_1: No such file or directory I looked at the advice here: https://wiki.freepascal.org/Lazarus/FPC_Libraries which is very straight forward, but I can't get it work. My /usr/lib is full of a profusion of variously named .so files as compiled by the openSSL build, but none of them are found by the linker. What's the -1_1  is that the version? or not? But where does crypto-1_1 even come from? I simply don't know. A typical declaration is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function FIPS_mode: TIdC_INT cdecl; external CLibCrypto;  and CLibCrypto is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  CLibCryptoRaw = 'libcrypto';  CLibSSLRaw = 'libssl';   SSLDLLVers: array [0..1] of string = ('', '.1.1');   {$IFDEF OSX}  CLibCrypto = CLibCryptoRaw+'-1_1.dylib';  CLibSSL = CLibSSLRaw+'-1_1.dylib';  {$ENDIF}  {$IFDEF LINUX}  {$IFDEF STATICLOAD_OPENSSL}  // experimentally, this is works for static binding by the linker  CLibCrypto = CLibCryptoRaw;  CLibSSL = CLibSSLRaw;  {$ELSE}  CLibCrypto = CLibCryptoRaw+'-1_1.so';  CLibSSL = CLibSSLRaw+'-1_1.so';  {$ENDIF}  {$ENDIF}  STATICLOAD_OPENSSL is true, so CLibCrypto is just 'libcrypto' so where does the '-1_1' come from? Lazarus 2.2.7 (rev lazarus_2_2_6-1-gada7a90f86) FPC 3.2.3 x86_64-linux-gtk2  on Ubuntu 22 ---------------------------------------------------------------------- Grahame Grieve · 2023-05-21 12:16 or a different question: how do you know what library the linker has found? What it's finding for openSSL 1.1 if I just leave it as CLibCryptoRaw+'.so.1.1' is not actually 1.1 it's 3.0 (judging by the routines the linker can't find) ---------------------------------------------------------------------- TRon · 2023-05-21 18:30 With regards to the linker question. It depends on the linker. Usually it has (command-line) options that you can add in order to make the linker more verbose. For gnu ld for example that means adding --verbose and/or --trace to its options (FPC can pass such options to the linker using the -k option). So, try to figure out what linker is used and what options it accepts. As an alternative (but I do not know if FPC does that on/for Mac) you can stop the linking process so that FPC outputs the linker script it will use to file. see alphabetical list of commandline options specifically -s and -k options ---------------------------------------------------------------------- zeljko · 2023-05-22 18:16 You must have -dev (-devel) packages installed to get it work when compiling (if you're on linux). ---------------------------------------------------------------------- Grahame Grieve · 2023-05-23 12:17 Thanks for the link to -k for -k--verbose. In the messages I find this: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i attempt to open /usr/lib/x86_64-linux-gnu/libcrypto.a succeeded  So that's ubuntu's standard openSSL 3.0, so at least I know why... but if the extern bindings are to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CLibCrypto = CLibCryptoRaw+'.so.1.1';  why is it finding that standard one? because it's version-less? So how do I get the linker to find my libcrypto.so.1.1? I will keep experimenting ---------------------------------------------------------------------- Grahame Grieve · 2023-05-23 12:28 Whatever the reason this in the custom parameters works: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -k-- library-path={openssl-location} ---------------------------------------------------------------------- Grahame Grieve · 2023-05-23 12:33 A follow up question to this. -k{passed-to-linker} - can I put something like -k--library-path={base}/relative/path so that it points somewhere in the project tree irrespective of where the developer has chosen to clone the repository? ---------------------------------------------------------------------- TRon · 2023-05-24 04:31 Quote from: Grahame Grieve on May 23, 2023, 02:33:08 pmA follow up question to this. -k{passed-to-linker} - can I put something like -k-- library-path={base}/relative/path so that it points somewhere in the project tree irrespective of where the developer has chosen to clone the repository? That work for me on Linux so in theory: yes Do note that some libraries are just link script wrappers that point to the real location/name of the library. Also note that (at least for me on Linux) the version numbers after the .so dot are not supported by FPC. You either need to remove those off the original file or create a link (without the numbers) to the filename with the dots yourself. Both are usually what installing the dev-package does for you automatically.