V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yunhui
V2EX  ›  Linux

linux 编译 curl 出错

  •  
  •   yunhui · 2015-11-12 22:43:09 +08:00 · 10823 次点击
    这是一个创建于 3058 天前的主题,其中的信息可能已经有所发展或是发生改变。

    编译 curl make 死活不通过,唉
    执行参数如下,谢谢各位帮忙看看

    这一步一切正常
    root@debian:~/curl-7.45.0# ./configure --with-ssl

    图片描述

    make

    一顿编译之后 ...... 然后出错了
    ../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method'
    ../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_set_alpn_protos'
    ../lib/.libs/libcurl.so: undefined reference to `SSL_get0_alpn_selected'
    collect2: error: ld returned 1 exit status
    make[2]: *** [curl] Error 1
    make[2]: Leaving directory `/root/curl-7.45.0/src'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/root/curl-7.45.0/src'
    make: *** [all-recursive] Error 1
    

    图片描述

    openssl 也是编译的,参数如下

    ./config  shared zlib
    已经编译成功
    
    root@debian:~/curl-7.45.0# openssl version
    OpenSSL 1.0.2d 9 Jul 2015
    root@debian:~/curl-7.45.0#
    
    45 条回复    2016-04-12 17:54:37 +08:00
    hardware
        1
    hardware  
       2015-11-12 23:06:38 +08:00
    指定 openssl 的路径了吗
    yunhui
        2
    yunhui  
    OP
       2015-11-12 23:14:53 +08:00
    @hardware ./configure --with-ssl 完了之后 ssl 已经是 enabled 状态了。也就是已经读取到了。
    yunhui
        3
    yunhui  
    OP
       2015-11-12 23:15:49 +08:00
    ./configure --with-ssl=/usr/local/ssl 照样不行、
    feather12315
        4
    feather12315  
       2015-11-12 23:16:30 +08:00 via Android
    能指定 ssl 源码文件吗?可以的话试试,别依赖系统库
    hardware
        5
    hardware  
       2015-11-12 23:21:44 +08:00
    那还有种可能是你编译 openssl 的时候 sslv2 没开
    yunhui
        6
    yunhui  
    OP
       2015-11-12 23:23:03 +08:00
    @feather12315 ./configure --with-ssl=~/openssl-OpenSSL_1_0_2d 似乎连 ssl 状态都是 no 了
    timonwong
        7
    timonwong  
       2015-11-12 23:25:33 +08:00
    openssl 自己编译的,是不是全局安装了。
    你的情况可能是冲突:
    1. 全局安装了 openssl 的 library 和 headers
    2. curl 找到了 openssl ,用的是你自己安装的 header
    3. curl 链接时,使用的是系统自带的 openssl lib
    yunhui
        8
    yunhui  
    OP
       2015-11-12 23:27:22 +08:00
    @hardware 如果是这样的华,我重新编译下 openssl
    yunhui
        9
    yunhui  
    OP
       2015-11-12 23:28:39 +08:00
    @timonwong

    系统是最小化安装的,什么基础工具包都没有,我一步一路撸过来的, openssl 系统一开始都没有的,我自己编译的
    wbsdty331
        10
    wbsdty331  
       2015-11-12 23:33:33 +08:00
    @timonwong 我也遇到这个问题了,原来是 debian 源里面装的 1.1 ,后来为了 nginx1.9.5 直接源码安装了 1.2 之后,每次编译 nginx 都要手动指定 openssl 源码库,不然就失败 不知道怎么搞
    yunhui
        11
    yunhui  
    OP
       2015-11-12 23:41:35 +08:00
    @hardware 直接关了 sslv2 openssl 编译方法 ./config shared zlib no-ssl2 编译中
    wdlth
        12
    wdlth  
       2015-11-12 23:44:39 +08:00
    1.0.2 废弃了部分东西,你可以用 1.0.1 编译,编译完不安装,直接指定路径编译 Curl 。

    https://www.openssl.org/news/changelog.html#x0
    wuruxu
        13
    wuruxu  
       2015-11-12 23:45:20 +08:00
    感觉你最后在 link 的时候,没有加上 -lssl
    znoodl
        14
    znoodl  
       2015-11-12 23:45:42 +08:00 via iPad
    @wbsdty331 我记得编译 nginx 所依赖的 openssl 是不需要编译的,而是指定 openssl 源码路径,和安装不安装 openssl 没有关系。

    好像以前的 nginx 版本需要编译 openssl ,你看下文档吧,记不太清了
    yunhui
        15
    yunhui  
    OP
       2015-11-12 23:51:45 +08:00
    @hardware 直接关了 sslv2 openssl 编译方法 ./config shared zlib no-ssl2 编译 openssl
    ```
    echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
    ldconfig -v
    ```
    然后然后~~~只是少了一行错误而已
    ```
    ../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_set_alpn_protos'
    ../lib/.libs/libcurl.so: undefined reference to `SSL_get0_alpn_selected'
    collect2: error: ld returned 1 exit status
    make[2]: *** [curl] Error 1
    make[2]: Leaving directory `/root/curl-7.45.0/src'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/root/curl-7.45.0/src'
    make: *** [all-recursive] Error 1
    ```
    yunhui
        16
    yunhui  
    OP
       2015-11-12 23:52:08 +08:00
    @wdlth 一会试试 1.0.1
    wbsdty331
        17
    wbsdty331  
       2015-11-12 23:53:42 +08:00
    @znoodl 我在编译 1.9.5 的时候没加 openssl 的路径 仍然报错
    yunhui
        18
    yunhui  
    OP
       2015-11-13 00:09:43 +08:00
    @wdlth 果然好像少了 2 个错误
    ../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_set_alpn_protos'
    ../lib/.libs/libcurl.so: undefined reference to `SSL_get0_alpn_selected'
    我重新试试
    yunhui
        19
    yunhui  
    OP
       2015-11-13 00:15:42 +08:00
    @znoodl ./config shared zlib no-ssl2 使用这招 不编译 ssl2 就不会报../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method'这个错误, ssl2 不编译也没事吧,落伍的协议了
    hardware
        20
    hardware  
       2015-11-13 00:27:26 +08:00
    @wdlth 编译完不安装 还不如直接在 curl 里屏蔽掉这个功能吧?
    hyq
        21
    hyq  
       2015-11-13 00:35:49 +08:00
    你如果用的 centos ,静态库和动态库放的路径是 /usr/lib ,但是系统配置的库路径在 /usr/lib64 。不知道是不是这个原因
    hyq
        22
    hyq  
       2015-11-13 00:36:50 +08:00
    刚才看漏了,是 debian 啊。。
    yunhui
        23
    yunhui  
    OP
       2015-11-13 00:48:16 +08:00
    @hyq 要不我也顺便也看看是不是这个关系
    yunhui
        24
    yunhui  
    OP
       2015-11-13 00:48:58 +08:00
    @yunhui 明显不是,哈哈
    msg7086
        25
    msg7086  
       2015-11-13 01:00:31 +08:00
    https://packages.debian.org/stretch/curl

    dep: libcurl3-gnutls (= 7.45.0-1+b1)

    你看官方都用 gnutls 口味了。

    PS: 能不能给个编译 curl 的理由?
    yunhui
        26
    yunhui  
    OP
       2015-11-13 01:16:21 +08:00
    @msg7086 呃呃呃,需求要 openssl~~~~
    abscon
        27
    abscon  
       2015-11-13 08:27:24 +08:00 via iPhone
    我也想知道楼主为何要亲自编译 curl 。这比编译失败的原因要重要得多
    yunhui
        28
    yunhui  
    OP
       2015-11-13 10:29:38 +08:00
    @abscon 主要是需要 openssl ,顺手撸了 curl , apt-get 的 curl 会自动下载 openssl
    abscon
        29
    abscon  
       2015-11-13 10:50:34 +08:00
    @yunhui 我觉得这么常见的需求 debian 应该有现成的包提供,比如 libcurl4-openssl-dev ?
    yunhui
        30
    yunhui  
    OP
       2015-11-13 11:33:29 +08:00
    @abscon 版本太低了。。
    wdlth
        31
    wdlth  
       2015-11-13 13:21:54 +08:00
    @hardware 可以不安装库到系统里面,静态编译进程序就可以了。
    abscon
        32
    abscon  
       2015-11-13 13:31:13 +08:00 via iPhone
    @yunhui 7.45 的版本,怎么就低了……
    你认为那个 4 是 curl 的版本?我觉得你最好花时间了解一下自己用的操作系统的包管理,否则很容易浪费时间。
    julyclyde
        33
    julyclyde  
       2015-11-13 14:33:04 +08:00
    新人要先学基础,别那编译软件这种破事练手,浪费时间也学不到什么东西
    yunhui
        34
    yunhui  
    OP
       2015-11-13 14:46:06 +08:00
    @abscon apt-get 的 curl 版本是 7.25 openssl 是 2013 年的
    yunhui
        35
    yunhui  
    OP
       2015-11-13 14:46:47 +08:00
    @julyclyde 没招,必须编译, apt-get 的 openssl 是 2013 年的
    Felldeadbird
        36
    Felldeadbird  
       2015-11-13 14:46:58 +08:00
    --with-ssl 要指明你的 openssl 编译地址。
    如:我的安装在 /opt/openssl 加上去就 OK 了。
    顺便吐槽一下这 CURL 和 OPENSSL 。 编译过程不能再当前目录进行,必须在别的目录。
    abscon
        37
    abscon  
       2015-11-13 15:47:21 +08:00
    @yunhui “系统是最小化安装的,什么基础工具包都没有,我一步一路[-哔-]过来的, openssl 系统一开始都没有的,我自己编译的”
    ------------------------------------
    好吧,看到这里我明白了你的乐趣所在。别用 Debian 了,向你推荐 Gentoo 和 Linux From Scratch 。另外 FreeBSD ports 也不错的,你可以指定 curl 是用 GNU TLS , WolfSSL 还是 OpenSSL 。
    yunhui
        38
    yunhui  
    OP
       2015-11-13 16:15:07 +08:00
    @abscon 其实主要是 apt-get 下载的 curl 会带上的 openssl1.01e 2013 版本太低了
    abscon
        39
    abscon  
       2015-11-13 16:34:27 +08:00
    @yunhui 你用的 Debian wheezy ? 换 jessie 或者 stretch 或者 sid 都可以有更高的版本啊。

    比如 sid 的是 1.0.2d
    yunhui
        40
    yunhui  
    OP
       2015-11-13 16:45:06 +08:00
    @abscon 现在的需求就是 debian7 这样,所以死这里了 唉
    Cu635
        41
    Cu635  
       2015-11-14 11:37:14 +08:00
    lz ,讲一下你的需求,到底是自己折腾着玩才编译,还是说是哪个教程教的你编译安装,还是说自己需要官方源软件包没有的哪个特性,还是什么?

    另外,需求是 debian7 ,是公司要求的吗?还是说之前是 debian7 ,自己没有信心升级?还是说其它工具依赖?还是怎么?

    在服务器上, debian 最好使用最新的 stable 版本,这样问题很少。觉得 nginx 、 php 这些版本太低了的话可以加入 dot-deb 源。
    yunhui
        42
    yunhui  
    OP
       2015-11-14 22:22:27 +08:00
    @Cu635 用的 debian7 仅仅是 mongodb 没写有 debian8 的版本,所以才选的,虽然我知道兴许是可行的,但是项目决定选 debian7 。然后抱歉,用的不是世界上最好的语言,用的是 nodejs~~~ 唉,当时纯粹就是想更新下 openssl 的版本, apt-get 下来的版本太低了是 1.0.1E 2013 的
    Cu635
        43
    Cu635  
       2015-11-15 10:46:22 +08:00
    那你在 debian 7 上加入 debian-security 源和 dot-deb 源试一试。升级时候再看看 openssl 版本是否满足你的要求了。

    加的时候注意 google 一下,看看怎么配置需要的仓库。

    不过我还是很好奇,“项目决定选 debian7 ”是不是除了 mongodb 还有其它的工具依赖于老版本?

    如果只是 mongodb 的依赖的的话,考虑一下现在就做好升级预案, mongodb 将来不久肯定会加入对 debian8 的支持的。
    yunhui
        44
    yunhui  
    OP
       2015-11-15 11:18:17 +08:00
    @Cu635 dot-deb 好像只是对 php nginx mysql 这类的支持较多。。。
    a6230589
        45
    a6230589  
       2016-04-12 17:54:37 +08:00
    如果是 openssl 不是安装在默认目录,就会报这个错,原因是 make 的时候会进行执行测试,此时查找到的 so 文件不是自己安装的。可以在 configure 之前使用如下命令解决:
    export LDFLAGS="-Wl,-rpath=/path/to/openssl/lib"
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5375 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 09:13 · PVG 17:13 · LAX 02:13 · JFK 05:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.