简体   繁体   中英

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. How to compile it as a static library and add it as a static library to another Eclipse C++ project?

Please give me step by step instructions.

Make the library:

File-->new-->C++ Project-->Project type-->static library-->empty project.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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