无法在Eclipse Juno 8.1.1 CDT C ++项目中添加静态库 [英] Can't add static library in Eclipse Juno 8.1.1 CDT C++ project

查看:328
本文介绍了无法在Eclipse Juno 8.1.1 CDT C ++项目中添加静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找到一个指南,如何链接一个静态库到我的Eclipse CDT项目,但我不能找到一个。我已经尝试过与Visual Studio 2010编译器和MiNGW。

I have been trying to find a guide how to link a static library to my Eclipse CDT project but I was not able to find one. I have tried both with Visual Studio 2010 compiler and MiNGW.

我使用Windows和Eclipse Juno 8.1.1,在项目设置 - > C / C + +构建 - 有这样的:

I use Windows and Eclipse Juno 8.1.1 , under Project Settings -> C/C++ Build -> Settings I have something like this :

Lib经理:

路径和符号:

推荐答案

您必须在Libraries(-l)中添加没有lib和.a的库名称,并在Libraries搜索路径(-L)中添加路径。

You have to add the library name without lib and .a in Libraries (-l) and adding the path in Libraries search path (-L).

但是,此问题也在 this stack。

However, this question is resolved also in this stack.

也在这网站,您可以找到很多有用的信息和关于如何包含链接库的解释。

Also in this site you can find a lot of usefull information and the explanation on how include linking library.

编辑

如文档中所述:


Q。如何向项目添加静态库文件? (诸如libmtm.a之类的文件)

Q. How do I add a static library file to a project? (Files such as libmtm.a)

A。首先,您需要将文件复制到Eclipse项目中。您可以通过简单地将其拖动到Eclipse中项目资源管理器树中的项目文件夹中来实现。
要链接库(静态库与对象文件类似):

A. First you will need to copy the file into your Eclipse project. You can do that by simply dragging it into the project folder in the "Project Explorer" tree in Eclipse. To link the library (A static library is used similarly to an object file):


  1. 打开项目,属性。

  2. 在该对话框中选择C ++ Build,Settings。

  3. 在工具设置选项卡下,选择链接器或MinGW C链接器或等效项,然后选择库。

  4. 在库下,按添加...按钮(绿色十字),并写入库名称,不带lib前缀和.a后缀。例如为了链接库文件libmtm.a写mtm。

  5. 在库搜索路径下,按添加...按钮,选择工作区并选择项目。

  1. Open Project, Properties.
  2. In that dialog select "C++ Build, Settings".
  3. Under the Tool Settings tab choose "Linker" or "MinGW C Linker" or equivalent and under that select "Libraries".
  4. Under "Libraries" press the "Add..." button (the green cross) and write the name of the library without the "lib" prefix and ".a" suffix. e.g. in order to link the library file libmtm.a write "mtm".
  5. Under "Library search path" press the "Add..." button, select workspace and select the project.


这篇关于无法在Eclipse Juno 8.1.1 CDT C ++项目中添加静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆