Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

c - why does the result of loading binary between on linux and on arm are so different?

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...