静态Git构建中链接的未定义引用

时间:2013-02-05 00:05:51

标签: linux git gcc linker makefile

我正在尝试在共享服务器上安装git(没有root访问权限或编译器),在我自己的机器(运行Arch Linux)上静态构建git,使用与服务器相同的处理器体系结构(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

3 个答案:

答案 0 :(得分:1)

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

除外

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

在第2步中。

答案 1 :(得分:0)

错误消息表明找不到

的定义
dlclose
dlerror
dleopen

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

答案 2 :(得分:0)

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