Chinaunix首页 | 论坛 | 博客
  • 博客访问: 273638
  • 博文数量: 150
  • 博客积分: 2396
  • 博客等级: 大尉
  • 技术积分: 1536
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-19 09:55
文章分类

全部博文(150)

文章存档

2021年(1)

2015年(9)

2014年(7)

2013年(50)

2012年(33)

2011年(1)

2010年(13)

2009年(36)

我的朋友

分类: LINUX

2012-09-20 11:13:20

hello.h

#ifndef HELLO_H
#define HELLO_H

#ifdef __cplusplus
extern "C"{
#endif
void hello(void);
#ifdef __cplusplus
};
#endif

hello.cpp

#include
#include "hello.h"
void hello()
{
  printf("hello ,this is c++ library\n");
}

g++  -c hello.cpp  -o hello.o
ar rsc libhello.a hello.o

hello_test.c
#include
#include "hello.h"
int main(void)
{
printf("begin to use libary\n");
hello();
return 0;
}

gcc  -c hello_test.c  -o hello_test.o

g++  -o hello_static hello_test.o -L. libhello.a

阅读(4156) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~