# Crystal-pg arm64 openssl

**URL:** <https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506>\
**Category:** Help & Support\
**Created:** [March 25, 2023, 12:33pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506 "2023-03-25T12:33:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [March 25, 2023, 12:33pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/1 "2023-03-25T12:33:04Z")

</div>

I’m trying to connect a PostgreSQL database to my Kemal app but when I try to run `crystal run src/app.cr` I get the following error message

```bash
Undefined symbols for architecture arm64:
  "_EVP_MD_size", referenced from:
      _*OpenSSL::Digest#digest_size:Int32 in O-penS-S-L-5858D-igest.o
      _*Digest::MD5@OpenSSL::Digest#digest_size:Int32 in D-igest5858M-D-5.o
  "_SSL_get_peer_certificate", referenced from:
      _*OpenSSL::SSL::Socket::Client@OpenSSL::SSL::Socket#peer_certificate:(OpenSSL::X509::Certificate | Nil) in O-penS-S-L-5858S-S-L-5858S-ocket5858C-lient.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

```

I installed Crystal with `brew install crystal` and then I ran `brew install openssl`.

I have no idea what to do to fix this and it does not really seem to be a solution found on Google (at least I have not been able to find any).

```auto
# crystal -v
Crystal 1.7.3 (2023-03-07)

LLVM: 14.0.6
Default target: aarch64-apple-darwin22.2.0

```

```auto
# crystal env
CRYSTAL_CACHE_DIR=$HOME/.cache/crystal
CRYSTAL_PATH=lib:/opt/homebrew/Cellar/crystal/1.7.3/libexec/../share/crystal/src
CRYSTAL_VERSION=1.7.3
CRYSTAL_LIBRARY_PATH=/opt/homebrew/Cellar/crystal/1.7.3/libexec/../../../../lib
CRYSTAL_OPTS=''

```

```auto
# simplified app.cr
require "db"
require "pg"
require "kemal"

DB.open "postgres://postgres:postgres@127.0.0.1:5432/mailbox_locator" do |db|
  db.exec <<-SQL
    CREATE TABLE IF NOT EXISTS mailboxes (
      ...
    );
  SQL
end

get "/" do
  # ...
  render "src/views/index.ecr"
end

Kemal.run

```

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [March 25, 2023, 2:48pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/2 "2023-03-25T14:48:27Z")

</div>

> <https://stackoverflow.com/questions/69895045/crystal-lang-on-apple-silicone-m1/69897927#69897927>

I think you just need `openssl@1.1`.

---

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [March 25, 2023, 2:54pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/3 "2023-03-25T14:54:07Z")

</div>

```bash
$ brew install openssl@1.1
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################## 100.0%
Warning: openssl@1.1 1.1.1t is already installed and up-to-date.
To reinstall 1.1.1t, run:
  brew reinstall openssl@1.1

```

looks like I already have it but I know I have `openssl@3` too because I did run `brew install openssl@3` the other day and I have `export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"` in my `.zshrc` file.

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [March 25, 2023, 3:10pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/4 "2023-03-25T15:10:13Z")

</div>

Try `export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}/opt/homebrew/opt/openssl@1.1/lib/pkgconfig` this part tho. To ensure pkg-config is able to find `openssl@1.1` libs.

---

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [March 25, 2023, 3:18pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/5 "2023-03-25T15:18:05Z")

</div>

```bash
$ export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
$ crystal run src/app.cr

```

resulted in the same error

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [March 25, 2023, 3:25pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/6 "2023-03-25T15:25:02Z")

</div>

What about `export CRYSTAL_LIBRARY_PATH=/opt/homebrew/lib:/usr/lib`?

(Basically just suggesting things from that SO post as it seems to be basically what you’re running into)

---

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [March 25, 2023, 3:28pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/7 "2023-03-25T15:28:35Z")

</div>

> [@Blacksmoke16](#):
>
> export CRYSTAL\_LIBRARY\_PATH=/opt/homebrew/lib:/usr/lib

Same error. I did see this post on SO earlier and I already tried all their suggestions as it was basically the only thing I could find where this error was mentioned.

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [March 25, 2023, 3:47pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/8 "2023-03-25T15:47:57Z")

</div>

Hmm well dang. I know this error usually relates to pkg-config/the linker not being able to find the proper libs. Unfortunately I don’t have an M1 mac to help test. My hunch is that it still has something to do with `CRYSTAL_LIBRARY_PATH` and/or `PKG_CONFIG_PATH` and needing to get them to find the right thing. But maybe someone who actually has an M1 will have a better idea.

---

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [March 25, 2023, 3:56pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/9 "2023-03-25T15:56:07Z")

</div>

Really appreciate your help 🙂

I did try to setup Jekyll the other day to run [kemalcr.com](https://kemalcr.com) locally and I got a lot of `openssl.h is missing` error. I found this answer [ruby - Can't install Jekyll - "fatal error: 'openssl/ssl.h' file not found" - Stack Overflow](https://stackoverflow.com/a/74340336) and ran some of the commands (it did not work btw 😅 ) - now I’m wondering if any of these commands could have changed something on my machine that now results in the error I’m facing now? 🤔

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/rogerdpack/32/117_2.png) [@rogerdpack](https://forum.crystal-lang.org/u/rogerdpack)\
**Post date:** [March 29, 2023, 8:35pm UTC](https://forum.crystal-lang.org/t/crystal-pg-arm64-openssl/5506/10 "2023-03-29T20:35:03Z")

</div>

Maybe remove all versions except 1.1? Theroetically the brew package should already be setting up the library path right?
