In essence, I want my main program to link properly to one library 'libA.so', and the symbols 'subFunc' from that library may come from another library(xxx), but those symbols 'funcB' will not be used by the main program.
I compile them as follows:
libA.so
int subfunc(int a, int b);
int funcB(int a, int b) {
return subfunc(a, b);
}
int funcA(int a, int b) {
return a + b;
}
main.cc
#include <stdio.h>
int funcB(int a, int b);
int main()
{
funcB(1,2);
printf("hello
");
return 0;
}
gcc --shared libA.cc -o libA.so
gcc main.cc libA.so -o main -Wl,--allow-shlib-undefined
./main
'./main' can run normally on linux,but when I cross compile them:
aarch64-linux-gnu-gcc --shared libA.cc -o libA.so
aarch64-linux-gnu-gcc main.cc libA.so -o main -Wl,--allow-shlib-undefined
then run on platform 'arm',
'./main' get notification:
./main: symbol lookup error: libA.so: undefined symbol: _Z7subfuncii
Any advices for me, I will be very grateful.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…