Setting static library in Eclipse c++ in Linux

1. Build static library project from Eclipse.

Setting static library in Eclipse c++ in Linux


2. Create header (hello.h) and source (hello.cc) file. Build them to create the static library.

Setting static library in Eclipse c++ in Linux

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;
}

3. Build test project. But hello.h could not be found and output() is not declared, if we try to build the project.

Setting static library in Eclipse c++ in Linux


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. 

Setting static library in Eclipse c++ in Linux


5. Add static library so that output() is declared.

Setting static library in Eclipse c++ in Linux


Now the test project is able to run correctly!


Setting static library in Eclipse c++ in Linux

上一篇:C语言 strftime 格式化显示日期时间


下一篇:c语言,string库函数itoa实现:将int转换为char*