c - 尝试在 Linux 上使用“gcc -L”将库添加到“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
...
解决方案
-L
每个 lib 目录都需要一个单独的目录。假设你真的想./bigint/src
成为一个 lib 目录:
gcc -L ../build/lib -L ./bigint/src <C file or object file> -lbigint
推荐阅读
- scala - 多态函数
- python - 根据另一个 DataFrame 创建包含具有值的 dicts 的 DataFrame
- c# - 正则表达式匹配由 1 个空格或 1 个连字符分隔的单词
- gson - 将 JSONobject 值获取到动态生成的 JSONobject 中的变量
- python-3.x - 使用单个 for 循环同时迭代集合和列表,它是如何工作的?
- html - 如何使用标签和过滤器将 index.html 的页脚显示到所有 html 页面?
- python - 仅更新给定的值并忽略 dynamodb 中的其他值
- laravel - Laravel 7 Route Group 在一些相关路线上返回 404
- powershell - 从 Azure DevOps 获取所有项目下的所有用户
- javascript - 谁能解释一下下面的代码?