Macos ld:找不到-lssl的库
我用自制软件安装了crystalMacos ld:找不到-lssl的库,macos,crystal-lang,Macos,Crystal Lang,我用自制软件安装了crystalbrew安装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.respons
brew安装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
$ 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`
错误:
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\u PATH=“$LIBRARY\u PATH:/usr/local/lib”
添加到~/.zshrc
及
在运行第二个Xcode select命令之前,我需要让Xcode完成安装。为openssl库提供pkgconfig路径为我解决了这个问题:
PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig" crystal <command>
PKG_CONFIG_PATH=“/usr/local/opt/openssl/lib/pkgconfig”crystal
添加包配置对我来说很有效,下面是添加包配置的命令,因此您无需每次都指定:
echo'export PATH=“/usr/local/opt/llvm@8/bin:$PATH“'>>~/.bash\u配置文件
source~/.bash_配置文件
我必须添加库路径来修复此问题
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
只需包含Lib
brew install openssl
echo 'export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/' >> ~/.zshrc
source ~/.zshrc