The application uses HsOpenSSL library, which is a binding for openssl. When I compile the application on MacOS (it’s ARM64), I have to do:
sudo ln -sf /opt/homebrew/Cellar/openssl@3/3.0.7 /usr/local/opt/openssl
for ARM64.
It’s strange but it works. But now, when I try to do the same for X86_64 with a command: stack --resolver lts-20.4 --arch x86_64 build
I get an error like:
...
<command line>: dlopen(/Xxx/.stack/snapshots/x86_64-osx/b1d675598b9b6c5f516e03f82c45d01becd6003e6128005b2b4acb8628b0f350/9.2.5/lib/x86_64-osx-ghc-9.2.5/libHSHsOpenSSL-0.11.7.2-1JX1qBi8YfpGDjk1ra3OXq-ghc9.2.5.dylib, 0x0005): symbol not found in flat namespace '_DSA_free'
...
I have installed separate Homebrew for x86_64 in /usr/local/homebrew. I installed openssl@3 with this brew instance: arch -x86_64 /usr/local/homebrew/bin/brew install openssl@3
, and I tried to create similar symlink:
sudo ln -sf /usr/local/homebrew/Cellar/openssl@3/3.0.7 /usr/local/opt/openssl
so everything looks fine for me, but the command stack --resolver lts-20.4 --arch x86_64 build
fails.
I tried to add the library path to extra-lib-dirs:
extra-lib-dirs:
- /usr/local/homebrew/Cellar/openssl@3/3.0.7/lib
and to use environment variable LDFLAGS: export LDFLAGS="-L/usr/local/homebrew/Cellar/openssl@3/3.0.7/lib"
but no success and to use the HsOpenSSL flags:
flags:
HsOpenSSL:
homebrew-openssl: true
The library in dlopen(…) really exists, the command file
reports it as for x86_64 architecture, which looks OK, but objdump -t ...lib/x86_64-osx-ghc-9.2.5/libHSHsOpenSSL-0.11.7.2-1JX1qBi8YfpGDjk1ra3OXq-ghc9.2.5.dylib
really reports a set of symbols marked as *UND*
:
...
0000000000000000 *UND* _DSA_do_sign
0000000000000000 *UND* _DSA_do_verify
0000000000000000 *UND* _DSA_free
0000000000000000 *UND* _DSA_generate_key
...
I have feeling that stack calls the linker wrongly when I try to compile the application for x86_64, or something similar, but no idea how to fix it as well as I am not sure that this is the problem actually. I can build the application for X86_64 platform with other (mine) dynamic libraries, but the problem is - 3rd party libraries, openssl in the case.
Also I tried to put all openssl x86_64’s libs to a folder where they are 100% “visible” for the compiler (where I keep my libraries), but the error was not fixed.
Any help, tips, hints are appreciated, I have not ideas more