Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld: library not found for -lssl

I installed crystal with homebrew brew install crystal-lang. I was able to compile and run a "Hello World!" program, but when I try to compile the example http server (with one slight modification) I get an error.

HTTP server:

require "http/server"

port = 3000

server = HTTP::Server.new(port) do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world! The time is #{Time.now}"
end

puts "listening on http://localhost:" + port.to_s
puts "listening on http://localhost:#{port}"
server.listen

Error:

$ crystal server.cr                                                                                                                                        ~/sw/crystal/Lied-Today
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc -o "/Users/Matt/.cache/crystal/crystal-run-server.tmp" "${@}"  -rdynamic  -lz `command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'` -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.21.1_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`

I've tried the following:

Adding export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" to ~/.zshrc.

and

$ xcode-select --install
$ xcode-select --switch /Library/Developer/CommandLineTools
like image 986
Jones Avatar asked Mar 16 '17 20:03

Jones


2 Answers

I had to add LIBRARY_PATH to fix this.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
like image 98
SanthoshKumar Avatar answered Sep 23 '22 22:09

SanthoshKumar


Just include the Lib

brew install openssl
echo 'export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/' >> ~/.zshrc
source ~/.zshrc
like image 31
ctwyw Avatar answered Sep 24 '22 22:09

ctwyw