Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75394
  • 博文数量: 11
  • 博客积分: 140
  • 博客等级: 入伍新兵
  • 技术积分: 208
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-22 00:51
个人简介

天外有天,人外有人。

文章分类

全部博文(11)

文章存档

2013年(10)

2012年(1)

我的朋友

分类: LINUX

2013-09-04 22:48:32

Linux下静态库文件的扩展名为".a"(Archieve), 静态库的文件名形式是libname.a。 动态库文件的扩展名为".so"(Shared Object),所有动态库文件名的形式是libname.so。如:线程函数库被称作 libthread.so。

vim myfunction.c
#include "myfunction.h"

int myfunction(void)
{
    printf("Myfunction\n");
    return 0;
}
vim test.c
#include
#include "myfunction.h"

int main(void)
{
    myfunction();
    return 0;
}

vim myfunction.h
#ifndef _MYFUNCTION_H
#define _MYFUNCTION_H
extern int myfunction(void);
#endif

gcc -fpic -shared -o libmyfunction.so myfunction.c

gcc -o test test.c

gcc -o test /btsom/chenjunhua/so/libmyfunction.so test.c
./test

sudo mv ./libmyfunction.so /usr/lib
gcc -o test -lmyfunction test.c
set |grep LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib
./test
阅读(1512) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~