libssh2 1.6版更改编译通过(OpenSSL 1.0.2d)


  转载请注明出处!
最近编译libssh2时,一直不能通过,参照libssh2和openssl源代码,对libssh2做如下修改。
1 在src/openssl.h 文件中增加如下头文件
  #include <openssl/rsa.h>
#include <openssl/dsa.h>

2 在src/openssl.h

src/openssl.h 
Showing the top two matches. Last indexed 

131#define libssh2_hmac_sha1_init(ctx, key, keylen) \
132 HMAC_Init(ctx, key, keylen, EVP_sha1())
133#define libssh2_hmac_md5_init(ctx, key, keylen) \
134 HMAC_Init(ctx, key, keylen, EVP_md5())
135#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \
改为如下

src/openssl.h 
Showing the top two matches. Last indexed 

131#define libssh2_hmac_sha1_init(ctx, key, keylen) \
132 HMAC_Init_ex(ctx, key, keylen, EVP_sha1(),NULL)
133#define libssh2_hmac_md5_init(ctx, key, keylen) \
134 HMAC_Init_ex(ctx, key, keylen, EVP_md5(),NULL)
135#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \

src/openssl.h 
Showing the top match. Last indexed 

139#define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
140#define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx)
141
142#define libssh2_crypto_init() OpenSSL_add_all_algorithms()
改为

src/openssl.h 
Showing the top match. Last indexed 

139#define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
140#define libssh2_hmac_cleanup(ctx) HMAC_CTX_cleanup(ctx)
141
142#define libssh2_crypto_init() OpenSSL_add_all_algorithms()
原因:
      可以查看openssl源码 hmac.h文件中(如下):这2个函数是有条件编译的 USE_DEPRECATED,  但是查看openssl的change log , 最新的openssl 默认是NO DEPRECATED, 故在编译libssh2时会报 NO DEFINE REFRENCE .
Changes between 1.0.2 and 1.1.0
   *) config has been changed so that by default OPENSSL_NO_DEPRECATED is used.
     Access to deprecated functions can be re-enabled by running config with
     "enable-deprecated". In addition applications wishing to use deprecated
     functions must define OPENSSL_USE_DEPRECATED. Note that this new behaviour
     will, by default, disable some transitive includes that previously existed
     in the header files (e.g. ec.h will no longer, by default, include bn.h)
     [Matt Caswell]
   
   
void HMAC_CTX_init(HMAC_CTX *ctx);

void HMAC_CTX_cleanup(HMAC_CTX *ctx);



#ifdef OPENSSL_USE_DEPRECATED

/* deprecated */

# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)



/* deprecated */

DECLARE_DEPRECATED(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,

const EVP_MD *md));



#endif

/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,

const EVP_MD *md, ENGINE *impl);

/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,

size_t len);

/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,
最后libssh2编译成功。
更改好的源文件地址: libssh2
要下载和编译Linux的libssh2.so本,可以按照以下步骤进行: 1. 首先,从libssh2官方网站(https://www.libssh2.org/)或者其他可靠的资源库中找到最新的libssh2本的源代码压缩包。 2. 下载源代码压缩包到本地计算机,可以使用命令行工具如wget或者通过浏览器下载。 3. 解压缩源代码压缩包,在命令行中使用tar命令进行解压缩。例如,使用以下命令解压缩压缩包: tar -zxvf libssh2-x.x.x.tar.gz (其中x.x.x代表源代码压缩包的本号) 4. 进入解压缩后的libssh2目录,使用cd命令切换到解压后的文件夹内。 5. 使用编译工具(如gcc)对libssh2进行编译,可以使用以下命令进行编译: ./configure make make install 注意:在编译之前,请确保您已经安装了必要的依赖项(如libssl-dev)。 6. 编译完成后,libssh2.so文件将会生成在系统默认的库文件路径中,一般为/usr/local/lib。如果您希望将其安装到其他位置,可以在configure命令中通过--prefix选项指定安装路径。 7. 可以使用ldconfig命令来刷新系统的动态链接器缓存,以便让系统找到新安装的libssh2.so文件。可以使用以下命令来刷新缓存: sudo ldconfig 8. 现在,您可以在您的应用程序中使用libssh2库进行开发和测试。记得在编译应用程序时,使用-L选项指定libssh2.so所在的目录,并使用-lssh2选项链接到libssh2库。 以上是一个简单的示例解释如何在Linux上下载和编译libssh2.so本。具体步骤和命令可能因系统本和安装环境而有所不同,建议在实际操作中参考官方文档或其他可靠资源。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值