/usr/bin/ld:找不到 -lz

/usr/bin/ld:找不到 -lz

我正在尝试在运行 ubuntu/trusty64 的虚拟机上在虚拟环境中安装 lxml,但是我收到下面的错误并且无法理解。

/usr/bin/ld: cannot find -lz

第一次发生此错误时,我研究了安装 lz。我使用包含 lz 的 sudo apt-get install mtools 安装了它,但错误仍然发生,因此我认为这可能是符号链接问题,也许文件应该链接到 lz,但不确定是什么文件。lz 有一个指向 uz 的符号链接,但我不知道它有什么影响,也不想更改它,以防它会破坏其他东西。有什么想法可以给我指明正确的方向吗?

building 'lxml.etree' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/vagrant/.virtualenvs/devenv/bin/python -c "import setuptools, tokenize;__file__='/home/vagrant/.virtualenvs/devenv/build/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yUqdLy-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/vagrant/.virtualenvs/devenv/include/site/python2.7 failed with error code 1 in /home/vagrant/.virtualenvs/devenv/build/lxml
Storing debug log for failure in /home/vagrant/.pip/pip.log

(devenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/woowoo/woowoo_webapp$ ls -l /usr/bin/ld
lrwxrwxrwx 1 root root 6 Sep 16 16:11 /usr/bin/ld -> ld.bfd
(devenv)$ vim /usr/bin/ld.bfd 
(devenv)$ ls -l /usr/bin/ld.bfd
-rwxr-xr-x 1 root root 1050912 Sep 16 16:10 /usr/bin/ld.bfd
(devenv)$ ls -l /usr/bin/ld
lrwxrwxrwx 1 root root 6 Sep 16 16:11 /usr/bin/ld -> ld.bfd
(devenv)$ ls -l /usr/bin/lzlrwxrwxrwx 1 root root 2 Oct 10  2013 /usr/bin/lz -> uz
(devenv)$ ls -l /usr/bin/uz
-rwxr-xr-x 1 root root 2496 Oct 10  2013 /usr/bin/uz

答案1

您需要安装 lxml 的构建依赖项才能对其进行编译。sudo apt-get build-dep python-lxml如果您在 apt 源中启用了源包数据,请尝试执行此操作。

缺少的不是lz命令,而是 zlib 库的开发文件。您需要安装zlib1g-dev才能获得它。

答案2

尝试以下三个之一:

  1. sudo apt-get install zlib1g-dev
  2. sudo apt-get install libz-dev
  3. sudo apt-get install lib32z1-dev

希望可以供大家参考“/usr/bin/ld:找不到-lz”更多细节。

相关内容