Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 静态Git构建中链接时未定义的引用_Linux_Git_Gcc_Linker_Makefile - Fatal编程技术网

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

Linux 静态Git构建中链接时未定义的引用,linux,git,gcc,linker,makefile,Linux,Git,Gcc,Linker,Makefile,我试图通过在自己的机器(运行Arch Linux)上静态构建git,并使用与服务器相同的处理器体系结构(x86_64)在共享服务器上安装git(无根访问或编译器),如中所述 当我运行make时,总是出现以下错误和故障: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': (.text+0x19): undefi

我试图通过在自己的机器(运行Arch Linux)上静态构建git,并使用与服务器相同的处理器体系结构(x86_64)在共享服务器上安装git(无根访问或编译器),如中所述

当我运行
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

错误消息表示找不到的定义

dlclose
dlerror
dleopen

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

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

我最终发现,建议运行稍微不同的.configure命令。最终对我有效的是,除了跑步

$。/configure--prefix=/home/myuser/git static CFLAGS=“${CFLAGS}-static”NO\u OPENSSL=1 NO\u CURL=1


在步骤2中。

我之前曾尝试添加LDFLAGS=-ldl,但我得到了相同的结果。是的,我看到了,但它在您的makefile中吗?没有显示实际命令的日志没有用处。下次应该使用
make V=1
。另外,请注意关于静态链接和glibc的警告。二进制文件可能无法在不同的系统上工作。