Ruby mysql2 gem 설치 시 libssl 오류 해결법
mysql2 gem 설치 과정에서
libssl library가 없다는 오류가 발생했다.
❯❯❯ gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. (생략) ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mysql2.bundle] Error 1 make failed, exit code 2
OpenSSL consists of two separate libraries: libcrypto and libssl. libcrypto is a general-purpose cryptography library which can be used alone. libssl is a TLS library which depends on libcrypto.
❯❯❯ brew reinstall openssl && brew link openssl --force (중략) ==> Summary 🍺 /usr/local/Cellar/openssl/1.0.2q: 1,794 files, 12.1MB Warning: Refusing to link macOS-provided software: openssl If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib —with-cppflags=-I/usr/local/opt/openssl/include" $ bundle