当前位置:网站首页>写一个可执行文件依赖.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
边栏推荐
猜你喜欢

手动配置DHCP服务

jenkins用到的插件

Routing and switching technology - static routing

OSPF和RIP的路由扩展配置

Unity3d+gameframework: resource analysis, resource dependency, circular dependency detection

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

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

@Requiredargsconstructor annotation use

DHCP 第二次实验

Hcip --- OSPF details
随机推荐
0 dynamic programming leetcodde313. super ugly number
Instant messaging websocket
Unity3d: ugui source code, rebuild optimization
Hcip-hcia knowledge review (II)
Routing and interface technology -- Summary of direct network
Build FRPC client in NAS [super brainless]
Eth-Trunk 配置实例学习记录
STP 配置实例学习记录
[database] basic theory
InheritableThreadLocal与阿里的TransmittableThreadLocal设计思路解析
PDF在线预览,pdf.js的使用
Unity3d: script execution sequence on scene loading gameobejct
Analysis of Internet Protocol (II)
es常见操作
Unity used trilib plug-in under URP pipeline to load model material incorrectly
openvpn部署
学习日记——(路由与交换技术)动态路由(rip协议)和静态路由
HCIP---HCIA知识回顾(一)
psutil监控的简单使用
为什么要搭建本地yum仓库?