1、编写my_print.c源文件,内容如下:

#include <stdio.h>

void cout(const char * message)
{
    fprintf(stdout, "%s\n", message);
}

2、编写my_lib.h头文件,内容如下:
 

#ifndef __MY_LIB_H__
#define __MY_LIB_H__

void cout(const char *);

#endif

3、编写test_static_lib.c源文件,内容如下:
 

#include <stdio.h>
#include "my_lib.h"


int main(int argc, char *argv[])
{
    cout("This is a static lib test!\n");

    return 0;
}

4、编译my_print.c源文件:
arm-hisiv500-linux-gcc -c my_print.c

      交叉编译环境下静态库的制作与测试

5、归档目标文件,得到静态库。

arm-hisiv500-linux-ar crv libmylib.a my_print.o

交叉编译环境下静态库的制作与测试

6、生成ELF文件:
arm-hisiv500-linux-gcc test_static_lib.c  -L. -lmylib -o test_static_lib

交叉编译环境下静态库的制作与测试

7、将ELF文件拷贝至开发板,执行

 

交叉编译环境下静态库的制作与测试

 

交叉编译环境下静态库的制作与测试

相关文章:

  • 2021-12-19
  • 2021-09-18
  • 2021-05-10
  • 2021-08-11
  • 2021-11-05
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2021-08-22
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案