Centos7编译安装git出错解决方案

在编译安装git时出现如下报错信息

imap-send.o: In function `sk_GENERAL_NAME_num':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_num'
imap-send.o: In function `sk_GENERAL_NAME_value':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_value'
imap-send.o: In function `sk_GENERAL_NAME_pop_free':
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_pop_free'
/usr/local/include/openssl/x509v3.h:165: undefined reference to `OPENSSL_sk_pop_free'
imap-send.o: In function `ssl_socket_connect':
/usr/local/src/git-2.11.1/imap-send.c:287: undefined reference to `OPENSSL_init_ssl'
/usr/local/src/git-2.11.1/imap-send.c:288: undefined reference to `OPENSSL_init_ssl'
/usr/local/src/git-2.11.1/imap-send.c:290: undefined reference to `TLS_method'
/usr/local/src/git-2.11.1/imap-send.c:303: undefined reference to `SSL_CTX_set_options'
collect2: error: ld returned 1 exit status
make: *** [git-imap-send] Error 1

问题有两种原因:

1. openssl与Anconda中自带的openssl冲突

    解决方法:设置/etc/profile 将含有Anconda路径的环境变量设置注释掉(需要重启,安装完git之后再改回来)

2. openssl的路径设置不对

    解决方法:在git编译步骤中的make操作之前,进行如下命令

which openssl // 获得openssl路径

/usr/local/openssl


./configure --with-openssl=/usr/local/openssl // 设置git的config

之后再进行make等操作

你可能感兴趣的:(Centos7,Git安装问题)