c - 链接器无法在 OSX 上的 Eclipse C 上找到现有库

标签 c eclipse macos

我有一个自定义库(.a 文件),我想将其添加到 Eclipse 中的 C 项目中。 我尝试将其添加到项目首选项 -> C/C++ 常规 -> 路径和符号 -> 库 中。此位置自动显示在项目首选项 -> C/C++ 构建 -> 设置 -> 工具设置 -> MacOS X C 链接器 -> 库

当我构建项目时,我在构建控制台中收到以下错误:

Building target: TestOfLibrary
Invoking: MacOS X C Linker
gcc  -o "TestOfLibrary"  ./src/TestOfLibrary.o   -l"/Users/me/workspaces/test/libs/mylib.a"
ld: library not found for -l/Users/me/workspaces/test/libs/mylib.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [TestOfLibrary] Error 1

库的路径正确,没有拼写错误,并且文件存在。

可能是什么问题?

最佳答案

@托伯

在 gcc 命令选项上,您可能需要添加库搜索路径标志。假设您正在链接静态库 (mylib.a),以下将是您要运行的命令/标志:

gcc TestOfLibrary.c -L/Users/me/workspaces/test/libs -lmylib

The directories searched include several standard system directories plus any > that you specify with -L.

Normally the files found this way are library files—archive files whose members > are object files.

进一步引用:Options for Linking .

话虽这么说,这是我的 Eclipse 配置,我会用它来进行相应的设置:

C/C++ 构建/设置:http://www.screencast.com/t/vJLsjzGVJ8N

让我知道进展如何。

关于c - 链接器无法在 OSX 上的 Eclipse C 上找到现有库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26110105/

相关文章:

c - 数组 C 中的结构初始化行为

ios - 将 IPA 上传到 App Store 时出错

css - Mac 无法在浏览器中呈现字体

java - Android java.lang.NullPointer。 Eclipse Juno - JDK7 路径错误?

macos - CFStringCreateWithFormat 期望什么样的字符串作为参数?

c - 删除 printf ("");破坏我的程序!我收到错误 : expected expression"making a char after switch case

c - 函数调用中参数的评估顺序?

c - 为什么这个函数给我无限循环?

java - 在 Eclipse Android 中添加新 Activity

android - XML Relative Layout order change Crashes 程序 (Android)