Install mysql2 gem on macos

Viewed 381

I'm trying to install mysql2 on Mac, as a default my openssl is located at /opt/homebrew/opt/openssl@1.1/bin/openssl

I installed mysql2 with LDFLAGS & CPPFLAGS using command:

sudo gem install mysql2 -v '0.5.3' -- \
  --with-ldflags=-L/opt/homebrew/opt/openssl@1.1/lib \
  --with-cppflags=-I/opt/homebrew/opt/openssl@1.1/include

But it resulted an error:

   2 warnings generated.
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

I tried several ways but it can not fix the issue.

1 Answers

Oh finally, I found an solution at here, it works great for me

rbenv exec gem install mysql2 -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.26/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.26 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.26/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.26/include 
Related