Thank you Kurt--this was indeed the solution I've been searching for. I was 
finally able to build a static binary. For future people stumbling across this 
conversation, I was able to compile successfully with the following strategy 
(note that these paths may have changed over time):

export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
export CSC_OPTIONS="-I/usr/local/opt/openssl@3/include 
-L/usr/local/opt/openssl@3/lib"

Then after installing the openssl egg, I could compile with:

csc -static myprogram.scm -L -lssl -L -lcrypto -o myprogram

Thanks again!

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, September 29th, 2021 at 5:08 PM, T. Kurt Bond 
<[email protected]> wrote:

> Have you tried setting CSC_OPTIONS to include the specific include and 
> library directories for the homebrew installed openssl, the ones under 
> /usr/local/Cellar/openssl*/VERSION/{include,lib}? That 
> [helped](https://tkurtbond.github.io/posts/2021/09/13/getting-the-homebrew-chicken-scheme-sqlite3-egg-to-use-the-homebrew-installed-sqlite3-include-files-and-library-files/)
>  me with getting the sqlite3 egg to build using the homebrew installed 
> sqlite3 (because the sqlite3 Apple supplies is obsolete). It's not exactly 
> the same situation, but maybe it will help.
>
> On Wed, Sep 29, 2021 at 4:58 PM Nicholas Van Horn <[email protected]> 
> wrote:
>
>> Hi all!
>>
>> I have a project that uses the OpenSSL egg. The code base historically ran 
>> fine. It runs both in interpreted fashion as well as compiled. It runs on 
>> both linux and MacOS, and has for several years. However, after updating to 
>> Chicken 5+ I am no longer able to build static binaries on MacOS (which I 
>> use for distributing the program). On linux I have no issues. The problem 
>> clearly arises from Mac's abandonment of OpenSSL for its own tooling. But 
>> this has been the case for some time, and I've already overcome this before. 
>> The issue appears to be a linker problem during compile time, likely due to 
>> how static binaries are handled in v5+. Here's my current setup:
>>
>> MacOS 11.6 (Big Sur)
>> Chicken 5.2.0
>> OpenSSL installed via homebrew
>>
>> My code runs just fine in interpreted mode (csi -s myprogram.scm). My goal 
>> is to compile to static binary. I use the following on linux to successfully 
>> achieve this:
>>
>> csc -static myprogram.scm -L -lssl -L -lcrypto -o myprogram
>>
>> On my mac I receive the following error:
>>
>> ld: library not found for -lssl
>> clang: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>>
>> Things I've tried (from the recommendation that homebrew outputs after 
>> installing openssl):
>>
>> export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
>> export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
>>
>> export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
>>
>> I have also followed the advice of a previous mailing list response from 
>> 2019 that specified how to get openssl working on MacOS:
>>
>> brew install openssl
>> export PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"
>> chicken-install openssl
>>
>> This has been what I've used to get the openssl egg working on a Mac. 
>> However, this doesn't seem to address the static compilation problem I'm 
>> encountering.
>>
>> Any help would be GREATLY appreciated.
>>
>> Thanks,
>> Nick
>
> --
> T. Kurt Bond, [email protected], https://tkurtbond.github.io

Reply via email to