这在我的主机上可以使用,但是在Raspberry PI上似乎不能使用。有人知道怎么回事吗?
我正在尝试交叉编译。我运行了以下代码:
arm-linux-gnueabi-gcc -Wall -fPIC -o mylib.o -c lib_test.c
arm-linux-gnueabi-gcc -shared -o libmylib.so mylib.o -lm
arm-linux-gnueabi-gcc -Wall -g -o test test.c -L. -lmylib
然后我对两个文件进行SCP操作,并在Raspberry PI上运行以下命令(是.so和可执行文件都在目录中)
LD_LIBRARY_PATH=. ./test
我明白了
./test: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
证明:
pi@raspberrypi:~/my_proj $ ls
libmylib.so test
pi@raspberrypi:~/my_proj $ LD_LIBRARY_PATH=. ./test
./test: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
pi@raspberrypi:~/my_proj $ find . -name "libmylib.so"
./libmylib.so