C++:eclipse CDT 中的外部库
现在我正在为我的 C/C++ 应用程序使用 eclipse CDT,但是当我链接外部库时出现问题,它无法在运行时正确加载,即使我将库文件放在源文件附近,我也给了库路径,并且它的名称正确。
项目目录:
- include(.h files)
- source(.cpp.files..)
- lib(libbozorth3.a,LSFMatcher.a)
我想将该静态库与我的应用程序链接起来,我按照以下步骤操作:
- 项目->属性->常规->路径和符号->包括目录路径和库(bozorth3.a,LSFMatcher.a),并添加库路径。
- 而且我还在链接器部分添加了相同的库
当我构建程序时它显示错误 找不到-lbozorth3.a 找不到 -lLSFMatcher.a
所以我需要正确的步骤将外部库添加到 c/c++ 应用程序。
Now I am using eclipse CDT for my C/C++ Application, but there is problem when I link my external library, it could not be loaded properly at run time, even through I put the library file near the source file, I gave the library path, and it's name correctly.
project directory:
- include(.h files)
- source(.cpp. files..)
- lib(libbozorth3.a,LSFMatcher.a)
I want link that static libraries with my application I follow this steps:
- project->properties->general->path and symbols->include directory path,and libraries(bozorth3.a,LSFMatcher.a),and add library path .
- and also i add the same library in linker section also
When I build the program it displays a error
cannot find -lbozorth3.a
cannot find -lLSFMatcher.a
So I need the correct steps to add the external library to c/c++ application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我通常配置
(参见下图,并将链接器标志中的路径交换为您在库搜索路径中使用的路径)
I normally configure
(see images below and exchange the path in the Linker flags to that one you used in the library search path)
您应该使用
-Wl,-rpath=${workspace_loc}/Liball
而不是-Wl,-rpath,${workspace_loc}/Liball
。另外,在library -l选项下添加库,例如。对于 libgcc.a 仅添加 gcc
you should use
-Wl,-rpath=${workspace_loc}/Liball
and not-Wl,-rpath,${workspace_loc}/Liball
.Also under library -l option add library like eg. for libgcc.a add only gcc
您应该注意括号中的内容:其他选项(-Xlinker [选项])。
传递选项的方式不同。而不是使用:
您必须使用:
即删除“-Wl”,并将第二个“,”替换为“”(空格)。
You should pay attention to what is in parentheses: Other options (-Xlinker [option]).
The way to pass options is different. Instead of using:
You must use:
That is, remove the "-Wl," and replace the second "," by " " (space).