2017-03-16 147 views
3

我安裝了自制的水晶brew install crystal-lang。我能夠編譯並運行「Hello World!」程序,但是當我嘗試編譯示例http服務器(稍作修改)時,出現錯誤。ld:找不到-lssl庫

HTTP服務器:

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 

錯誤:

$ 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` 

我已經試過如下:

添加export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"到〜/ .zshrc。

$ xcode-select --install 
$ xcode-select --switch /Library/Developer/CommandLineTools 

回答

5

我需要讓Xcode中完成安裝,運行第二Xcode中選擇命令之前。