简体   繁体   English

如何将Eclipse C ++项目构建为库并将其添加到另一个项目

[英]How to build Eclipse C++ project as a library and add it to another project

I have a standard Eclipse C++ project with some code. 我有一个带有一些代码的标准Eclipse C ++项目。 How to compile it as a static library and add it as a static library to another Eclipse C++ project? 如何将其编译为静态库并将其作为静态库添加到另一个Eclipse C ++项目?

Please give me step by step instructions. 请给我逐步说明。

Make the library: 制作库:

File-->new-->C++ Project-->Project type-->static library-->empty project. 文件->新建-> C ++项目->项目类型->静态库->空项目。

Add the library: 添加库:

quote from the documentation: 从文档中引用:

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

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):

    Open Project, Properties.
    In that dialog select "C++ Build, Settings".
    Under the Tool Settings tab choose "Linker" or "MinGW C Linker" or equivalent and under that select "Libraries".
    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".
    Under "Library search path" press the "Add..." button, select workspace and select the project.

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

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