libssh2编译错误(configure error: cannot find OpenSSL or Libgcrypt)解决方法

简介: 如果按标准的configure执行: ./configure --prefix=/data/users/mooon/third-party/libssh2 --with-openssl --with-libssl-prefix=/data/users/mooon/third-par...
如果按标准的configure执行:
./configure --prefix=/data/users/mooon/third-party/libssh2 --with-openssl --with-libssl-prefix=/data/users/mooon/third-party/openssl --without-libgcrypt-prefix

得到如下错误时:
checking for shared library run path origin... done
checking for libssl... no
checking for libgcrypt... no
configure: error: cannot find OpenSSL or Libgcrypt,
try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH

请改成如下:
./configure --prefix=/data/users/mooon/third-party/libssh2 CPPFLAGS="-I/data/users/mooon/third-party/openssl/include" LDFLAGS="-L/data/users/mooon/third-party/openssl/lib"

上述方法为何可以解决问题:
道理非常简单,就是满足它的需求,报的是找不到OpenSSL,既然--with-libssl-prefix没生效,那么就直接通过CPPFLAGS和LDFLAGS来指定,当执行“./configure --help”可以看到这个支持的。甚至可以通过查看config.log日志文件来了解这方面的信息,以后遇到类似的问题,都可以采取类似的办法,软的不行来硬的。

遇到这个错误的一个重要原因是:OpenSSL没有安装在标准的目录下,如果以./configure不带--prefix安装OpenSSL,则可能不会出现这个问题。
相关文章
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
解决办法:configure: error: C compiler cannot create executables错误
解决办法:configure: error: C compiler cannot create executables错误
427 0
编译libpng出错:pnglibconf.c fatal error: zlib.h 没有那个文件或目录
编译libpng出错:pnglibconf.c fatal error: zlib.h 没有那个文件或目录
86 0
编译OpenJDK8:configure: error: Could not find all X11 headers
编译OpenJDK8:configure: error: Could not find all X11 headers
128 0
解决办法:Could not find bison
解决办法:Could not find bison
129 0