Recent

Author Topic: Static Linking OpenSSL and OSX version  (Read 24175 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #15 on: November 30, 2021, 05:39:11 am »
well, what current branch is tied to openSSL 1.1? I need openSSL 1.1...

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: Static Linking OpenSSL and OSX version
« Reply #16 on: November 30, 2021, 05:23:43 pm »
well, what current branch is tied to openSSL 1.1? I need openSSL 1.1...

There is no branch for OpenSSL 1.1.x.  As I stated a few days ago:

First, that branch is OLD, and probably needs to be deleted. Indy's latest OpenSSL 1.1x support code is in this pull request instead.

The OpenSSL 1.1.x code is still a WIP, use the master branch and add the pull request's code on top of it.  OpenSSL 1.1.x support is being implemented as a new set of SSLIOHandler components that are specific to 1.1.x, not as an update to the existing SSLIOHandler components that are for 1.0.2 and earlier.
« Last Edit: November 30, 2021, 05:28:07 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #17 on: December 02, 2021, 01:22:39 pm »
Remy, I'm not explaining myself well, that is the code I'm using for Indy

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #18 on: December 04, 2021, 09:46:00 pm »
well, back to this... I now have an fpc.cfg, and it has an entry in it for -XR pointing to the relevant command line SDK, which does exist. And I remove it, I get "Error: ld: framework not found Cocoa". So I think the compiler is seeing it, but I still get "Error: ld: library not found for -lc". Is there a way to get the command line passed to ld?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Static Linking OpenSSL and OSX version
« Reply #19 on: December 05, 2021, 12:09:12 am »
I think these configuration issues are related to how you originally installed FPC. We can keep patching the existing configuration files for every issue that comes up or delete everything and start afresh with the official installers from SourceForge which I know work.

I think your current configuration issue might be resolved by adding the line:

Code: Text  [Select][+][-]
  1. -Fl/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib

to your fpc.cfg file.

If there's any more configuration issues though, I would strongly recommend deleting everything and starting again with the official installers and then building the development version of FPC (and Lazarus if necessary) from source. It will be quicker in the long run.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #20 on: December 05, 2021, 11:53:50 am »
That line already exists in the fpc.cfg file. And I have deleted everything and reinstalled following the instructions on the wiki page


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Static Linking OpenSSL and OSX version
« Reply #21 on: December 05, 2021, 12:12:45 pm »
1. if you run Lazarus and create a new project for an application and then compile that otherwise empty project, does it fail?

2. if yes, please cut and paste the contents of Lazarus > View > IDE Internals > About FPC from Lazarus version down to just before Defines.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #22 on: December 06, 2021, 09:54:09 am »
I create a new application and compile it - compiles ok. (doesn't run - some LLDB problem I'll get back to later). Then I give it the option -Xt and get the image attached.

View as requested:

Lazarus version: 2.3.0
Lazarus revision: main-2_3-757-g217459a76f
Lazarus build date: 2021/12/02
Lazarus was compiled for x86_64-darwin
Lazarus was compiled with FPC 3.2.2

Environment variables:
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PP=
FPCDIR=
USESVN2REVISIONINC=
USER=grahame
HOME=/Users/grahame
PWD=
LANG=
LANGUAGE=

Global IDE options:
LazarusDirectory=../work/lazarus/laz_main/
Resolved LazarusDirectory=/Users/grahame/work/lazarus/laz_main/
Project's CompilerFilename=$(CompPath)
Resolved Project's CompilerFilename=/usr/local/bin/fpc
Default CompilerFilename=/usr/local/bin/fpc
Resolved default compilerFilename=/usr/local/bin/fpc
CompilerMessagesFilename=
Resolved CompilerMessagesFilename=/Users/grahame/work/lazarus/fpc_main/compiler/msg/errore.msg

Project:
lpi=
Directory=
TargetOS=
TargetCPU=
CompilerFilename=$(CompPath)
CompilerOptions=

Active target:
TargetOS=darwin
TargetCPU=aarch64

FPC executable:
Compiler=/usr/local/bin/fpc
Options=
CompilerDate=12/04/21 10:02:05 PM
RealCompiler=/usr/local/bin/ppca64
RealCompilerDate=12/04/21 10:02:05 PM
RealTargetOS=darwin
RealTargetCPU=aarch64
RealCompilerInPath=
Version=3.3.1
CfgFilename=/etc/fpc.cfg

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Static Linking OpenSSL and OSX version
« Reply #23 on: December 06, 2021, 10:13:24 am »
As far as I know macOS frameworks, unlike iOS frameworks, are dynamic and not static which would explain why the Cocoa framework is not being found when you try to link it statically.

[Edit]

Quote
The executable code in a framework bundle is a dynamically linked, shared library—or, simply, a dynamic shared library. This is a library whose code can be shared by multiple concurrently running programs.
Apple Source.
« Last Edit: December 06, 2021, 10:22:37 am by trev »

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #24 on: December 06, 2021, 11:00:59 am »
umm, so what do I do differently? Or I can't do static linking on OSX because of that?


Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #25 on: December 06, 2021, 11:02:19 am »
but also, the Cocoa framework is found, unless I set -XR to something wrong. It's 'c' that's not being found

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Static Linking OpenSSL and OSX version
« Reply #26 on: December 06, 2021, 11:13:22 am »
Argh - not sure why I got hung up on Cocoa except the fact that frameworks are dynamic. Brain not keeping up with my typing.

There is no static libc library in macOS. Instead, there is the dynamic system library (/usr/lib/libSystem.dylib) which includes, among other libraries, libc.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #27 on: December 06, 2021, 11:23:28 am »
..so I'm lost. What I want do it sounded really simple: statically link libcrypto.a and libssl.a, which I have in my path, into my application, so that I can work around the fact the libssl dependencies on libcrypto do not meet OSX hardened application requirements. I added $linklib for both of them, but they don't actually seem to be linked, which is why I was trying -Xt... perhaps I shouldn't be? is what I want to do possible?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Static Linking OpenSSL and OSX version
« Reply #28 on: December 06, 2021, 11:28:52 am »
Sure, you can statically link your own library into an FPC application - see the examples in my Wiki  article on macOS Static Libraries where I give examples of statically linking both FPC and C libraries.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 364
Re: Static Linking OpenSSL and OSX version
« Reply #29 on: December 07, 2021, 11:15:27 am »
Well, and it turns out it that is that easy - once the compile stuff is all sorted out, $linklib works just fine for openSSL. Now, to check it works after hardening...

 

TinyPortal © 2005-2018