当前位置:网站首页>写一个可执行文件依赖.so的测试用例
写一个可执行文件依赖.so的测试用例
2022-07-23 05:47:00 【蓝色卡布达】
export PATH="/home/he/edge/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin:$PATH"
如果makefile编译报错,那就是每个命令前应该是tab一下而不是空格。
1、printlib文件夹下三个文件
Makefile:
CROSS_COMPILE = aarch64-none-linux-gnu-
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
SOURCE_ROOT = $(shell pwd)
CFLAGS := -Wall -O2 -fno-builtin
CPPFLAGS := -lm
INCLUDE_DIR := -I $(SOURCE_ROOT)/ \
-I$(SOURCE_ROOT)/include
APP_NAME=libprinttest.so
all: $(APP_NAME)
APP_OBJECTC += printlib.c
STATIC_OBJ_O = $(patsubst %.c, %.o, $(APP_OBJECTC))
STATIC_OBJ_C = $(foreach file, $(STATIC_OBJ_O), $(file) )
$(STATIC_OBJ_C) : %.o:%.c
$(CC) $(INCLUDE_DIR) $(CPPFLAGS) -c -fPIC $(APP_OBJECTC)
$(APP_NAME): $(STATIC_OBJ_C)
$(CC) -shared $(CPPFLAGS) -o $(APP_NAME) ./*.o
clean:
@rm -f *.o *.so
.PHONY: clean
printlib.c:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void myPrint()
{
printf("world\n");
}
printlib.h:
#ifndef jasonPrint__h
#define jasonPrint__h
void myPrint();
#endif
在printtest文件夹下
Makefile:
VERSION :=$(shell date +1.%y.%m.%d)
CROSS_COMPILE ?= aarch64-none-linux-gnu-
DEBUG ?= -s
APATH := $(shell pwd)
C_SRCS := $(wildcard *.c)
C_OBJS := $(patsubst %.c,%.o,$(C_SRCS))
TAGS := printtest
CC := $(CROSS_COMPILE)gcc
STRIP := strip
CFLAGS := -O2 -Wall -I. -I../printlib
LFLAGS := -L. -L../printlib
LIBS := -lpthread -lprinttest
MKFLAGS := --no-print-directory
.PHONY: all clean app
all: app
app: $(C_OBJS)
$(CC) $(CFLAGS) $(LFLAGS) -o $(TAGS) $^ $(LIBS)
%.o:%.c
$(CC) $(CFLAGS) $(LFLAGS) -c $< -o [email protected]
clean:
rm -rf *.o *.*~ $(TAGS)
printlib.h:
#ifndef jasonPrint__h
#define jasonPrint__h
void myPrint();
#endif
main.c:
/* * main.c * * Created on: Mar 9, 2017 * Author: root */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <getopt.h>
#include <pthread.h>
#include <ctype.h>
#include <stdint.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include "printlib.h"
void printtest(void)
{
while (1) {
sleep(5);
printf("hello ");
myPrint();
}
}
int main(int argc, char **argv)
{
int ret = 0;
printtest();
return ret;
}
直接编译就行。
打包镜像:
Dockerfile:
FROM ubuntu
ADD libprinttest.so /usr/lib
ADD printtest /
CMD ["/printtest"]
docker buildx build --platform linux/arm64 -t printtest:v1.0 .
docker save 8a350c65e6e2 -o my_img.tar
边栏推荐
- Hcip --- mGRE comprehensive experiment
- 帧中继网配置实例学习记录
- Hcip --- HCIA knowledge review (I)
- Unity3d: script execution sequence on scene loading gameobejct
- 以go语言为例类比侦探推理来讲解【性能分析】
- LSM-tree(Log Structured-Merge Tree)的理解
- 在二叉排序树中删除节点
- [database] basic theory
- InheritableThreadLocal与阿里的TransmittableThreadLocal设计思路解析
- 学习日记(路由与交换技术)——浮动静态路由和缺省路由
猜你喜欢

Unity used trilib plug-in under URP pipeline to load model material incorrectly

学习日记——(路由与交换技术)三层交换机

学习日记(路由与交换技术)——浮动静态路由和缺省路由

HCIP---GRE协议和MGRE环境,以及OSPF协议的相关知识点

How to write a web page with a common text editor

Hcip --- condition matching and OSPF Protocol

FTP实验及概述

即时通讯WebSocket

MySQL performance optimization, index optimization

Hcip - HDLC and PPP protocols
随机推荐
为什么要搭建本地yum仓库?
Take go language as an example to explain [performance analysis] by analogizing detective reasoning
学习日记——(路由与交换技术)OSPF协议
MySQL performance optimization, index optimization
Analysis of Internet Protocol (I)
DNS域名解析服务
Unity mouse controls camera drag, rotation and zoom (simulation editor camera function)
HCIP---OSPF细节讲解
HCIP-HCIA知识回顾(二)
PDF Online preview, use of pdf.js
学习日记(路由与交换技术)——浮动静态路由和缺省路由
Article on the basic technology needed to build hybrid app
Learning diary - (routing and switching technology) ACL access control list
剖析Redis服务器
第一类错误离我们有多远
Delete node in binary sort tree
2小时1000人吃饭,要多少台座椅?
helm安装rancher
@RequiredArgsConstructor注解使用
[database] basic theory