C++:eclipse CDT 中的外部库

发布于 2024-12-26 13:27:57 字数 480 浏览 2 评论 0原文

现在我正在为我的 C/C++ 应用程序使用 eclipse CDT,但是当我链接外部库时出现问题,它无法在运行时正确加载,即使我将库文件放在源文件附近,我也给了库路径,并且它的名称正确。

项目目录:

  1. include(.h files)
  2. source(.cpp.files..)
  3. lib(libbozorth3.a,LSFMatcher.a)

我想将该静态库与我的应用程序链接起来,我按照以下步骤操作:

  1. 项目->属性->常规->路径和符号->包括目录路径和库(bozorth3.a,LSFMatcher.a),并添加库路径。
  2. 而且我还在链接器部分添加了相同的库

当我构建程序时它显示错误 找不到-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:

  1. include(.h files)
  2. source(.cpp. files..)
  3. lib(libbozorth3.a,LSFMatcher.a)

I want link that static libraries with my application I follow this steps:

  1. project->properties->general->path and symbols->include directory path,and libraries(bozorth3.a,LSFMatcher.a),and add library path .
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江南烟雨〆相思醉 2025-01-02 13:27:57

我通常配置

  1. 库、
  2. 库搜索路径(编译所需)、
  3. 运行时搜索路径(-rpath 链接器选项)

(参见下图,并将链接器标志中的路径交换为您在库搜索路径中使用的路径)

库搜索路径
运行时搜索路径的链接器选项

I normally configure

  1. the library
  2. the library search path (Needed for compiliation)
  3. the runtime search path (-rpath Linker option)

(see images below and exchange the path in the Linker flags to that one you used in the library search path)

Library Search path
Linker options for runtime search path

浮生未歇 2025-01-02 13:27:57

您应该使用 -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

寄意 2025-01-02 13:27:57

您应该注意括号中的内容:其他选项(-Xlinker [选项])。

传递选项的方式不同。而不是使用:

-Wl,-rpath,'${ProjDirPath}/../../system/lib'

您必须使用:

-rpath '${ProjDirPath}/../../system/lib'

即删除“-Wl”,并将第二个“,”替换为“”(空格)。

在此处输入图像描述

在此输入图像描述

You should pay attention to what is in parentheses: Other options (-Xlinker [option]).

The way to pass options is different. Instead of using:

-Wl,-rpath,'${ProjDirPath}/../../system/lib'

You must use:

-rpath '${ProjDirPath}/../../system/lib'

That is, remove the "-Wl," and replace the second "," by " " (space).

enter image description here

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文