交叉编译中的 --sysroot 等等在编译时的作用
--sysroot=dir 的作用
如果在编译时指定了-sysroot=dir 就是为编译时指定了逻辑目录。编译过程中需要引用的库,头文件,如果要到/usr/include目录下去找的情况下,则会在前面加上逻辑目录。
如此处我们指定 -sysroot=/home/shell.albert/tools/toolschain_arm/4.4.3/arm-none-linux-gnueabi/sys-root
将dir作为逻辑根目录(搜索头文件和库文件)。比如编译器通常会在 /usr/include 和 /usr/lib 中搜索头文件和库,使用这个选项后将在 dir/usr/include 和 dir/usr/lib 目录中搜索。如果使用这个选项的同时又使用了 -isysroot 选项,则此选项仅作用于库文件的搜索路径,而 -isysroot 选项将作用于头文件的搜索路径。这个选项与优化无关,但是在 CLFS 中有着神奇的作用。
-rpath=dir
Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option. If -rpath is not used when linking an ELF executable, the contents of the environment variable LD_RUN_PATH will be used if it is defined.
-rpath-link=dir
When
using ELF or SunOS, one shared library may require another. This
happens when an ld -shared link includes a shared library as one of the
input files.When
the linker encounters such a dependency when doing a non-shared,
non-relocatable link, it will automatically try to locate the required
shared library and include it in the link, if it is not included
explicitly. In such a case, the -rpath-link option specifies the first
set of directories to search. The -rpath-link option may specify a
sequence of directory names either by specifying a list of names
separated by colons, or by appearing multiple times.This
option should be used with caution as it overrides the search path that
may have been hard compiled into a shared library. In such a case it is
possible to use unintentionally a different search path than the
runtime linker would do.
The
difference between -rpath and -rpath-link is that directories specified
by -rpath options are included in the executable and used at runtime,
whereas the -rpath-link option is only effective at link time. Searching
-rpath in this way is only supported by native linkers and cross
linkers which have been configured with the --with-sysroot option.
-L: “链接”的时候,去找的目录,也就是所有的 -lFOO 选项里的库,都会先从 -L 指定的目录去找,然后是默认的地方。
-rpath: “运行”的时候,去找的目录。运行的时候,要找 .so 文件,会从这个选项里指定的地方去找。对于交叉编译,只有配合 --sysroot 选项才能起作用。
-rpath_link
(或者 -rpath-link):这个也是用于“链接”的时候的,例如你显示指定的需要 FOO.so,但是 FOO.so 本身是需要
BAR.so 的,后者你并没有指定,而是 FOO.so 引用到它,这个时候,会先从 -rpath-link 给的路径里找。
也就是说,-rpath指定的路径会被记录在生成的可执行程序中,用于运行时。
-rpath-link 则只用于链接时。
rpath-link的格式:
./configure --cross-prefix=/home/zhou/android/android_adt/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/home/zhou/android/android_adt/ndk/platforms/android-9/arch-arm --disable-shared --disable-symver --disable-everything --enable-gpl --enable-runtime-cpudetect --enable-decoder=h263 --enable-encoder=h263 --enable-encoder=libx264 --enable-parser=h264 --enable-libx264 --enable-decoder=h264 --prefix=/home/hzh/temp/vpu/build/ffmpeg/ --extra-cflags= -DANDROID -D__thumb__ -mthumb -I../build/x264//include --extra-ldflags= -L../build/x264//lib -Wl,-rpath-link,../build/x264//lib --extra-cxxflags=-Wno-multichar -fno-exceptions -fno-rtti
如果有多个rpath, 则:
-Wl,-rpath=/home/oracle/db_1/lib -Wl,-rpath=/home/app/oracle
也可以简写,注意是”:”,和PATH的路径分隔符一样,还要注意中英文字符:
-Wl,-rpath=/home/oracle/db_1/lib:/home/app/oracle
另外,如果有多个rpath,路径最好用绝对路径,不然有些时候configure 那一步过不了, 如ffmpeg。
bash 脚本里的到绝对路径的方法:
# bash脚本里 = 前后不能有空格,等号前后不能有空格,赋值
VPU_WRAPPER=../../vpu-helper/vpu_wrapper
pushd $VPU_WRAPPER
VPU_WRAPPER_DIR=`pwd`
popd EXTRA_CFLAGS="$EXTRA_CFLAGS -I$VPU_WRAPPER_DIR"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$VPU_WRAPPER_DIR/lib"
echo $EXTRA_LDFLAGS
# pushd 和 popd 会改变当前文件专属的目录路径,只对当前文件有效,退出当前文件的执行后立即失效
makefile里
CROSS_DIR = ../arm-2012.09/bin
CROSS_PREFIX = arm-none-linux-gnueabi-
CC = $(shell cd $(CROSS_DIR) && pwd)/$(CROSS_PREFIX)gcc
AR = $(shell cd $(CROSS_DIR) && pwd)/$(CROSS_PREFIX)ar
STRIP = $(shell cd $(CROSS_DIR) && pwd)/$(CROSS_PREFIX)strip
RANLIB= $(shell cd $(CROSS_DIR) && pwd)/$(CROSS_PREFIX)ranlib
@echo "CC is: '$(CC)'"
$(warning "CC is: $(CC)")
# $(shell cd $(CROSS_DIR)),改变目录只针对当前语句有效,退出当前语句后目录改变结果立即失效,即这一句不影响文件里的目录路径,只影响自己这一句。
交叉编译中的 --sysroot 等等在编译时的作用的更多相关文章
- webRTC中回声消除(AEC)模块编译时aec_rdft.c文件报错:
webRTC中回声消除(AEC)模块编译时aec_rdft.c文件报错. 原因是: 局部变量ip跟全局变量冲突的问题,可以将局部变量重新命名一下,就可以通过编译了. aec_rdft.c修改以后文件代 ...
- 预编译加速编译(precompiled_header),指定临时文件生成目录,使项目文件夹更干净(MOC_DIR,RCC_DIR, UI_DIR, OBJECTS_DIR),#pragma execution_character_set("UTF-8")"这个命令是在编译时产生作用的,而不是运行时
预编译加速编译 QT也可以像VS那样使用预编译头文件来加速编译器的编译速度.首先在.pro文件中加入: CONFIG += precompiled_header 然后定义需要预编译的头文件: PREC ...
- java中的异常机制(编译时异常)
/ * 1 异常机制的原理 * 异常是什么:就是错误的另外一种说法; * 在java中,有一个专门模拟所有异常的类,所有的异常都必须继承这个类:Throwable; * 本质是:当程序出错以后,jvm ...
- gtk+2.0中函数set_widget_font_size()函数在编译时未定义的解决办法
自己写一个头文件即可,代码如下: 在.c文件中包含该头文件即可
- 将子类对象引用赋值给超类对象 JAVA 编译时多态性
将子类对象引用赋值给超类对象 JAVA 编译时多态性(转) (2012-05-10 11:24:05) 转载▼ 标签: 杂谈 分类: 也无晴_soft 1.通过将子类对象引用赋值给超类对象引用变量来实 ...
- 在xcode运行编译时,编译成功,但项目中显示缺少该文件,这是只要关闭重启xcode即可。
在xcode运行编译时,编译成功,但项目中显示缺少该文件,这是只要关闭重启xcode即可.
- 在Linux下安装PHP过程中,编译时出现错误的解决办法
在Linux下安装PHP过程中,编译时出现configure: error: libjpeg.(a|so) not found 错误的解决办法 configure: error: libjpeg.(a ...
- MVC 4 中编译时,让View 也弹出异常
前言 MVC在编译时,不会提示View中的错误,我们在发布项目的时候会一个一个的提示异常,项目大的时候会非常头疼,因为每次发布都需要至少5分钟,最后收到只有一个异常信息,如果页面异常过多,例如最近整理 ...
- Android runProguard配置 导致module lib 中的包编译时无法识别
今天写代码时用到了另一个lib型的工程,把它添加到dependencies后,在原工程中可以引用lib中的文件了,但是编译时就会报错,提示包不存在,后来在build.gradle中设置runProgu ...
随机推荐
- 对React的理解
转自:http://www.cocoachina.com/webapp/20150721/12692.html 现在最热门的前端框架有AngularJS.React.Bootstrap等.自从接触了R ...
- PHP优化小结
1.echo 比 print 快,并且使用echo的多重参数(指用逗号而不是句点)代替字符串连接,比如echo $str1,$str2.如果使用echo $str1.$str2 就会需要 PHP 引擎 ...
- yii2源码学习笔记(十二)
继续了解controller基类. /** * Runs a request specified in terms of a route.在路径中指定的请求. * The route can be e ...
- 2016-10-31 reload
经历了创业公司的欠薪后,决定重新开始,从原本着力于如何快速入门与实现变更为巩固基础再出发. 2016-10-31
- 坑爹的NSIS转义符:$ (在NSIS的MessageBox中写换行文字)
最近的项目中,发现了NSIS一个比较坑的地方:$ 不但是变量常量的开头,还是一个转义字符. 大家有没有发现,NSIS写的脚本中,如果要让弹出消息框中的文字带换行功能,“\r\n” 是不是很不管用呢? ...
- 【转】MyBatis中Like语句使用方式
http://www.cnblogs.com/littleCode/p/3727476.html oracle数据库: SELECT * FROM user WHERE name like CONCA ...
- C语言写解一元二次方程程序心得
前言:在网上看到不少解一元二次方程的小程序,在使用时总得出一大堆小数,感觉很不爽,遂自己重新写了一遍. 首先,先回忆一下一元二次方程的求根公式: 分别读取二次项.一次项和常数项系数并且求出delta ...
- Manacher 算法-----o(n)回文串算法
回文的含义是:正着看和倒着看相同,如abba和yyxyy Manacher算法基本要点:用一个非常巧妙的方式,将所有可能的奇数/偶数长度的回文子串都转换成了奇数长度:在每个字符的两边都插 ...
- 快速搭建Web服务器软件PHP+Apache+MySQL
搭建网站或者博客,需要一个合适的 Web 服务器.除了如下能在购买的虚拟空间上进行操作外,我们也可以在自己的电脑上搞定,因为可以用来方便快捷地测试网站或者博客主题,无论是 Wordpress.Joom ...
- 【UVA 11865】 Stream My Contest (二分+MDST最小树形图)
[题意] 你需要花费不超过cost元来搭建一个比赛网络.网络中有n台机器,编号0~n-1,其中机器0为服务器,其他机器为客户机.一共有m条可以使用的网线,其中第i条网线的发送端是机器ui,接收端是机器 ...