【问题标题】:Undefined Reference at Linking in Static Git Build在静态 Git 构建中链接的未定义参考
【发布时间】:2013-02-05 00:05:50
【问题描述】:

我正在尝试将 git 安装在共享服务器上(没有 root 访问权限或编译器),方法是在我自己的机器(运行 Arch Linux)上静态构建它,并使用与服务器相同的处理器架构 (x86_64),如在this guide.

当我运行make 时,我总是遇到这些错误和失败:

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x2c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x37): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x364): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x422): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x494): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x552): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x5c2): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x62d): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x65a): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x6ef): undefined reference to `dladdr'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x749): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x7aa): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [git-imap-send] Error 1

【问题讨论】:

  • 不显示实际命令的日志没有用处。下次你应该使用make V=1。另外,请注意有关静态链接和 glibc 的警告。您的二进制文件可能无法在不同的系统上运行。

标签: linux git gcc linker makefile


【解决方案1】:

我终于发现了a different guide,它建议运行一个稍微不同的 .configure 命令。最终为我工作的是this guide,除了运行

$ ./configure --prefix=/home/myuser/git-static CFLAGS="${CFLAGS} -static" NO_OPENSSL=1 NO_CURL=1

在第 2 步中。

【讨论】:

    【解决方案2】:

    错误信息表示找不到

    的定义
    dlclose
    dlerror
    dleopen
    

    你需要确保你的makefile在链接应用程序时有-ldl

    【讨论】:

    • 我之前曾尝试添加 LDFLAGS=-ldl ,但得到了相同的结果。
    • 是的,我看到了,但它在你的 makefile 中吗?
    【解决方案3】:

    LDFLAGS 用于链接器标志。 LIBS 用于链接库。混淆它们通常不是问题,但在静态库或链接器启用了--as-needed 选项的情况下,库的顺序很重要,并且在使用它的库之前传递的任何-l 都将被忽略。

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 2014-04-28
      • 1970-01-01
      • 2019-07-24
      • 2016-01-29
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多