linux使用下使用动态与静态库
感觉对这个有些晕,做了个实验,弄清楚了。
实验思路,用同一份代码编译同时生成动态和静态库,通过测试程序调用,看调用的是动态库还是静态库。
生成静态库代码:
/***********hellod.h*************/
#ifndef _HELLO_S_H
#define _HELLO_S_H
void prints(char *str);
#endif
/*hellod.c*/
#include "hellod.h"
#include <stdio.h>
void printd(char *str)
{
printf("print in static way:%s",str);
}
gcc -c -o hellod.o hellod.c
ar cqs libhellod.a hellod.o
生成的静态库为libhellod.a
生成动态库代码:
将上面hellod.c中的打印语句,打印输入:print in dynamic way。以示区别。
gcc -shared -o libhellod.so hellod.c
生成的动态库为libhellod.so。
测试代码main.c
#include "hellod.h"
int main(void)
{
char *text = "hello,world\n";
printd(text);
}
使用静态库:gcc -o hello main.c -static -L./ -lhellod
执行生成文件,打印:print in static way:hello,world
使用动态库: gcc -o hello main.c -L./ -lhellod
执行后,打印 print in dynamic way:hello,world
相关文档:
例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......
体验一下linux下编写和使用动态库与静态库,范例:helloworld程序。
首先编写静态库:
hellos.h
#ifndef _HELLO_S_H
#define _HELLO_S_H
void prints(char *str);
#endif
hellos.c
#include "hellos.h"
#include <stdio.h>
void prints(char *str)
{
printf("print in sta ......
1.点号进度显示code 1
#!/bin/sh
#输出"."进度条函数,兼容bsh、ksh、bash
#首先trap 1 2 3 15信号,重要
trap 'kill $BG_PID;echo;exit' 1 2 3 15
function dots
{
stty -echo >/dev/null 2>&1
  ......