1. Build static library project from Eclipse.
2. Create header (hello.h) and source (hello.cc) file. Build them to create the static library.
codes of hello.h
#ifndef HELLO_H_ #define HELLO_H_ void output(); #endif /* HELLO_H_ */
codes of hello.h
#include <iostream> using namespace std; void output() { cout<<"I am static library!"<<endl; }
4. Add Includes so that hello.h could be found. One can also add Includes through C/C++ Build->Settings->Tool Settings->GCC C++ Compiler->Includes.
5. Add static library so that output() is declared.
Now the test project is able to run correctly!
Setting static library in Eclipse c++ in Linux
原文:http://blog.csdn.net/jsc0218/article/details/19235681