尝试在 Linux 上使用"gcC语言 L"将库添加到"C"项目中 - 错误

  • 本文关键字:添加 项目 错误 语言 Linux gcC c
  • 更新时间 :
  • 英文 :


嗨,我试图为我的 C 项目添加一个库来执行类任务,但我无法让它工作。

当我使用gcc -L ../build/lib ./bigint/src -lbigint时,它会显示错误:

/usr/bin/ld: ./bigint/src/ can not be found: File format not recognized
/usr/bin/ld: -lbigint can not be found
collect2: error: ld returned 1 exit status

我的目录看起来像这样:

root <- here im in the terminal trying, using the command
- bigint
-- src
--- bigint.c
--- bigint.h
--- bigint.h.gch
--- bigint.o
--- libbigint.a
--- support.h
--- support.g.gch
-- tst
- project.c
- project.h
...

您需要为每个 lib 目录提供一个单独的-L。假设你真的希望./bigint/src是一个lib目录:

gcc -L ../build/lib -L ./bigint/src <C file or object file> -lbigint

最新更新