Production and use of arm dynamic library and static library

1. Make and use dynamic library

Production and compilation:

aarch64-linux-gnu-gcc -c -o main.o main.c
aarch64-linux-gnu-gcc -c -o sub.o sub.c
aarch64-linux-gnu-gcc -shared -o libsub.so sub.o sub2.o sub3.o(可以使用多个.o 生成动态库)
aarch64-linux-gnu-gcc -o test main.o -lsub -L /libsub.so    /所在目录/

Run:
① First put libusb.so in the /lib directory on the PC or board, and then you can run the test program.
② If you don't want to put libusb.so in /lib, you can also put it in a directory such as /a, and then execute as follows:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/a
./test

2. Make and use static library

aarch64-linux-gnu-gcc -c -o main.o main.c
aarch64-linux-gnu-gcc -c -o sub.o sub.c
aarch64-linux-gnu-ar -r libsub.a sub.o sub2.o sub3.o(可以使用多个.o 生成静态库)
aarch64-linux-gnu-gcc -o test main.o libsub.a (如果.a 不在当前目录下,需要指定它的绝对或相对路径)

Run:
No need to put the static library libsub.a on the board.

Guess you like

Origin blog.csdn.net/qq_18077275/article/details/108907133