嗨,我试图为我的 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