简体   繁体   English

如何在 Eclipse C++ 项目中包含静态链接库?

[英]How do I include a statically linked library in my Eclipse C++ project?

I have an open-source library that's distributed in source form.我有一个以源代码形式分发的开源库。 After I run the Makefile, I end up with a .h file and a .a file that I then want to include in a project that I'm working on.运行 Makefile 后,我最终会得到一个.h文件和一个.a文件,然后我想将它们包含在我正在处理的项目中。 I'm familiar with how I can add these by editing a Makefile manually or by invoking the compiler from the command line, but I'm not sure how I can add these to my Eclipse C++ project, created using the CDT .我熟悉如何通过手动编辑 Makefile 或通过从命令行调用编译器来添加这些,但我不确定如何将这些添加到使用CDT创建的 Eclipse C++ 项目中。

I'm currently using Eclipse Indigo.我目前正在使用 Eclipse Indigo。 I found some instructions for older versions of Eclipse, but the menus aren't what are described.我找到了一些关于旧版本 Eclipse 的说明,但菜单不是所描述的。 I poked around a bit, and didn't see anything familiar.我四处看了看,没有看到任何熟悉的东西。

right click on the project name in the project explorer with the project being opened, select project properties.在打开项目的项目资源管理器中右键单击项目名称,选择项目属性。 Then select C/C++ General -> Paths and Symbols -> includes -> GNU C++ and add the path to your header file.然后选择 C/C++ General -> Paths and Symbols -> includes -> GNU C++ 并将路径添加到您的头文件中。 You should do the same for you library under : C/C++ General -> Paths and Symbols -> Libraries -> Add , and add your library file path.您应该在以下位置为您的库执行相同的操作: C/C++ General -> Paths and Symbols -> Libraries -> Add ,并添加您的库文件路径。

How do I add an external library to my C++ project?如何将外部库添加到我的 C++ 项目中?

Go to Your Project's Properties by right clicking on project's name and selecting properties.通过右键单击项目名称并选择属性,转到您的项目属性。 Click on "C/C++ Build".单击“C/C++ 构建”。 Under Settings->Tool Settings Tab, click on GCC C Linker / Libraries.在设置->工具设置选项卡下,单击 GCC C 链接器/库。 Then add a library and a search path.然后添加一个库和一个搜索路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM