Jon*_*nes 5 macos crystal-lang
我用自制软件安装了水晶brew install crystal-lang.我能够编译并运行"Hello World!" 程序,但当我尝试编译示例http服务器(稍作修改)时,我收到一个错误.
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
Run Code Online (Sandbox Code Playgroud)
错误:
$ 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`
Run Code Online (Sandbox Code Playgroud)
我尝试过以下方法:
添加export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"到〜/ .zshrc.
和
$ xcode-select --install
$ xcode-select --switch /Library/Developer/CommandLineTools
Run Code Online (Sandbox Code Playgroud)
小智 14
我不得不添加 LIBRARY_PATH 来解决这个问题。
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
Run Code Online (Sandbox Code Playgroud)
小智 5
只需包含 Lib
brew install openssl
echo 'export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/' >> ~/.zshrc
source ~/.zshrc
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2684 次 |
| 最近记录: |