Linux学习笔记——如何在交叉编译时使用共享库

Linux学习笔记——如何在交叉编译时使用共享库

在较为复杂的项目中会利用到交叉编译得到的共享库(*.so文件)。在这种情况下便会产生以下疑问,例如:
    【1】交叉编译时的共享库是否需要放置于目标板中,如果需要放置在哪个目录中。
    【2】交叉编译时的共享库是否需要放置于宿主机中,如果需要放置于哪个目录中。
    【3】交叉编译时如何指定共享库
    【4】程序运行时如何查找共享库
 

 

【1】交叉编译时的共享库是否需要放置于目标板中,如果需要放置在哪个目录中。
    交叉编译之后的共享库需要复制到目标板中,最好放置于/usr/lib或/lib中,当然也有其他的方法,在这里不详细说明。

【2】交叉编译时的共享库是否需要放置于宿主机中,如果需要放置于哪个目录中。
    交叉编译时确切的说链接过程中需要指定共享库的问题,通过-L指定目录,通过-l指定共享库名称。但是此时交叉编译的共享库最好不要放置于宿主机的/lib或/usr/lib中,以免产生混淆。
    综合【1】和【2】,libtest.so同时存在于目标板和宿主机中。

【3】交叉编译时如何指定共享库

    通过-L指定目录,通过-l指定共享库名称

 

【4】程序运行时如何查找共享库

 最直观的方法,复制到/usr/lib目录中,让linux系统自动查找。

 

对于处于默认库搜索路径之外的库,需要将库的位置添加到库的搜索路径之中。

展开阅读全文

求助!!交叉编译时出错

08-05

安装完arm-linux-gcc后打算编译一个helloworld的程序,结果出现如下错误rnrnrn[root@localhost c]# arm-linux-gcc hello.crnIn file included from hello.c:1:rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:34:21: error: stddef.h: No such file or directoryrnIn file included from /opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:75,rn from hello.c:1:rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:53:21: error: stdarg.h: No such file or directoryrnIn file included from /opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:75,rn from hello.c:1:rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:332: error: expected specifier-qualifier-list before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:364: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:373: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:489: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:491: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/libio.h:493: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_IO_sgetn'rnIn file included from hello.c:1:rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:312: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:319: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:347: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:352: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:355: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:361: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:363: error: format string argument not a string typern/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:365: error: expected declaration specifiers or '...' before 'size_t'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:366: error: expected declaration specifiers or '...' before '__gnuc_va_list'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:367: error: format string argument not a string typern/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:678: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:684: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fwrite'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:706: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread_unlocked'rn/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root/usr/include/stdio.h:708: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fwrite_unlocked'rnrnrn有大神遇到过吗,求解答 论坛

没有更多推荐了,返回首页