Mac安装openssl,找不到环境

时间:2018-08-06 03:12:34

标签: node.js macos openssl

我已经安装了openssl。当我输入openssl时,命令行可以识别它。但是我的节点configure找不到它。

请参见下面的图片

enter image description here

我尝试在.bash_profile中添加路径

,并尝试使用此one中的一些技巧 但它们都不起作用

1 个答案:

答案 0 :(得分:2)

如果您使用openssl安装了brew,则可能需要从以下位置设置LDFLAGSCPPFLAGS

brew info openssl
  

此公式仅适用于小桶,这意味着它没有符号链接到/ usr / local,   因为苹果已经弃用OpenSSL,而是使用自己的TLS和加密库。

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

如果您尝试链接,则会收到类似以下的警告:

$ brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

您可以做的是创建一个符号链接,以便编译器可以找到这些库:

$ ln -s /usr/local/opt/openssl/include/openssl /usr/local/include

那应该可以让您编译node-v0.6.1

$ ./configure
Checking for program g++ or c++          : /usr/bin/g++
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for program gcc or cc           : /usr/bin/gcc
Checking for gcc                         : ok
Checking for library dl                  : yes
Checking for openssl                     : yes
Checking for library util                : yes
Checking for library rt                  : not found
Checking for fdatasync(2) with c++       : no
'configure' finished successfully (0.998s)