linux 下动态库、静态库嵌套使用
linux下静态库嵌套使用
前提是你会在linux下调用静态库和动态库和Makfile编程(当然不会Makfile直接在终端命令也成)
本例是先由StringLen.h,StringLen.c生成librak.a
然后利用StringLen2.h,StringLen2.并调用librak.a生成librak2.a
最后利用StringLen3.h,StringLen3.c调用librak2.a 生成librak3.so
--------------------------------------------------------------------------------------
#StringLen.h:
#ifndef _STRINGLEN_H__
#define _STRINGLEN_H__
int Strlen(char *pStr);
#endif
#StringLen.c:
#include<stdio.h>
#include<assert.h>
#include "StringLen.h"
int Strlen(char *pStr)
{
unsigned long ulLength;
assert(NULL != pStr);
ulLength = 0;
while(*pStr++)
{
ulLength++;
}
return ulLength;
}
gcc -Wall -c *.c
ar rc librak.a *.o
------------------------------------------------------------------------------------
#StringLen2.h:
#ifndef _STRINGLEN_H2__
#define _STRINGLEN_H2__
#ifdef __UDT
#include "StringLen.h"
#endif
int Strlen2(char *pStr);
#endif
#StringLen2.c:
#include<stdio.h>
#include<assert.h>
#include "StringLen2.h"
int Strlen2(char *pStr)
{
unsigned long ulLength;
#ifdef __UDT
ulLength = Strlen(pStr);
#else
ulLength = -1;
#endif
return ulLength;
}
gcc -Wall -c *.c -D__UDT
ar rc librak2.a *.o
------------------------------------------------------------------------------------
相关文档:
一.前言
Linux拥有丰富各种源代码资源,但是大部分代码在Windows平台情况是无法正常编译的。Windows平台根本无法直接利用这些源代码资源。如果想要使用完整的代码,就要做移植工作。因为C/C++ Library的不同和其他的一些原因,移植C/C++代码是一项困难的工作。本文将以一个实际的例子(Tar)来说明如何把Linux代码移植 ......
Book Note: Linux Device Driver Dos and Don'ts
http://janitor.kernelnewbies.org/docs/driver-howto.html
what a hardened (robust) device
driver should mean and how it should be implemented and measured.
1.3 Robust device drivers
-Follows the Linux CodingStyle.
-Efficient in managing faults and ha ......
--孔建军(Kongove.CN)
2008.11.12
首先,让我们来看几组令人振奋的数据。现在订阅Linux内核邮件列表[1],每天的邮件流量大概在500份左右;执行"grep "^P:"
MAINTAINERS |sort -u|wc
-l",对内核子系统维护者进行统计,得到的结果是534人;从2007到2008年,平均每天有4300行代码添加到内核,有180 ......
Linux I2C核心、总线与设备驱动
注:
在linux2.6.32版本中有这样的代码与注释:
struct i2c_driver {
unsigned int class;
/* Notifies the driver that a new bus has appeared or is about to be
* removed. You should avoid using this if y ......
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NTP_SERVER "clock.via.net"
#define ......