如何在Linux环境下编译lib 库

export LD_LIBRARY_PATH=./

g++ -o libhell.so --share -fPIC hell.c hell.h    // 生成.lib文件

g++ -o hao -L. -lhell haowangli.c

/ 这个是 hell.h

#include <stdio.h>

void say();

/

/ 这个是 hell.c

#include <stdio.h>

#include "hell.h"

void say()

{

printf("hello world\n");

}

/

 

/ 这个是 haowangli.c

#include <stdio.h>

#include <iostream>

#include "hell.h"

using namespace std;

void say()

{

printf("hello world\n");

}

/

posted on 2013-11-25 17:02  hualimengyu  阅读(1107)  评论(0编辑  收藏  举报

导航