首页 > 编程语言 > 详细

Setting shared (dynamic) library in Eclipse c++ in Linux

时间:2014-02-15 16:33:45      阅读:575      评论:0      收藏:0      [点我收藏+]

1. Build shared library project from Eclipse.

bubuko.com,布布扣


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

bubuko.com,布布扣

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 shared 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.

bubuko.com,布布扣


4. Add Includes so that hello.h could be found. One can also add Includes through C/C++ General->Paths and Symbols->Includes->Languages>GNU C++. 

bubuko.com,布布扣


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

bubuko.com,布布扣


6. Now we can build the test project. However, it could not run correctly.

bubuko.com,布布扣


7. Add LD_LIBRARY_PATH and its value (shared library path) in Run Configurations.

bubuko.com,布布扣

An alternative step of step 7 is using -R option to point out the run-time path. Currently, the link-time path and run-time path are separated.  This method is better than using LD_LIBRARY_PATH because LD_LIBRARY_PATH is globally effective. 

bubuko.com,布布扣

Now it is ok to run!

Setting shared (dynamic) library in Eclipse c++ in Linux

原文:http://blog.csdn.net/jsc0218/article/details/19237737

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!