链接器错误:/ usr/bin/ld:找不到-lc

问题描述:

我试图编译this code一段时间。具体来说,我正在尝试使用给定的mac编译avx2代码。但是,我总是得到以下错误。 我查了很多,但无法找到解决方案。如果您能帮我找到解决方案,我将非常高兴。链接器错误:/ usr/bin/ld:找不到-lc

/usr/bin/ld: cannot find -lc

collect2: error: ld returned 1 exit status

make: *** [test/test_kyber] Error 1

gcc版本

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

锵版本:

clang version 3.4.2 (tags/RELEASE_34/dot2-final)

Target: x86_64-redhat-linux-gnu

Thread model: posix

输出运行make命令。

/usr/bin/gcc -Wall -Wextra -O3 -fomit-frame-pointer -msse2avx -mavx2 -march=native -static -o test/test_kyber kyber.c poly.c polyvec.c fips202.o fips202x4.c precomp.c ntt.c verify.c indcpa.c consts.c kex.c nttlevels0t4.s nttlevels5t7.s mul_coefficients.s polyvec_pointwise_acc.s poly_add.s poly_sub.s cbd.s poly_freeze.s crypto_stream_aes256ctr.c keccak4x/KeccakP-1600-times4-SIMD256.o randombytes.c test/test_kyber.c

/usr/bin/ld: cannot find -lc

collect2: error: ld returned 1 exit status

make: *** [test/test_kyber] Error 1

+5

好吧,这是一个失败。 * scnr * ...但是要认真的说,'找不到-lc'听起来像是你的工具链安装中的严重问题......你甚至能够在该机器上编译**任何东西**? –

+0

通常,我使用gcc。它一直都在运作。 – Rick

+0

那么,你的链接项目中的Makefile被硬连线到'clang'用于一组特定的输入文件(不知道为什么),所以'clang'在你的机器上工作吗? –

非常感谢您的帮助和时间。我明白了这个问题。 makefile会添加一个-static标志,但在我们的办公室机器上,我们没有静态libc.a.因此,错误“找不到-lc”。我删除了静态标志,现在它工作正常。 我认为我们不需要静态libc.a,但我必须更仔细地检查。

+0

期待一个静态的'libc'?这非常糟糕。静态链接到'libc'通常是一个糟糕的主意。由于'libc'是系统的接口,如果系统调用发生变化,任何系统更新都可能会中断与'libc'静态链接的程序。 –

+0

确实。我不知道为什么作者添加了静态标志。 – Rick