简体   繁体   English

交叉编译和库

[英]Cross-compilation and libraries

During a cross-compilation I got this linker error: 在交叉编译期间,出现此链接器错误:

/home/tech/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lfontconfig

This is the g++ command line: 这是g ++命令行:

/home/tech/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/mnt/rasp-pi-rootfs/opt/vc/lib -Wl,-rpath-link,/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/rasp-pi-rootfs/lib/arm-linux-gnueabihf -mfloat-abi=hard --sysroot=/mnt/rasp-pi-rootfs -Wl,-O1 -o fontconfig fontconfig.o   --sysroot=/mnt/rasp-pi-rootfs -lpthread -L/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/ -lfreetype -lfontconfig 

And

ls /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libfontconfig*

/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libfontconfig.so.1
/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libfontconfig.so.1.8.0

I don't understand "why" the linker cannot find that library. 我不明白链接器为什么找不到该库。 What do you suggest to do in such a case to investigate further? 在这种情况下,您建议做什么以进一步调查?

Linker requires import library with .a extension of the library for linker operations because it contains the signatures of classes and functions needed by the linker for linking while .so libraries are shared objects used at runtime. 链接程序要求导入库带有扩展名.a的链接库,以进行链接程序操作,因为它包含链接程序链接所需的类和函数的签名,而.so库是运行时使用的共享库。

You need to find the directory where you have libfontconfig.a (eg: through the command locate libfontconfig.a or 'find / -name libfontconfig.a') and then add it to the command line with -L/path/of/directory. 您需要找到libfontconfig.a所在的目录(例如,通过命令找到libfontconfig.a或'find / -name libfontconfig.a'),然后使用-L / path / of / directory将其添加到命令行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM