
今天把cygwin下的bin目录添加到PATH后,直接运行g++, gcc, 显示“访问被拒绝” (access denied).
竟然那么诡异,上网查资料,网上的解决方案说:
检查g++.exe, gcc.exe是否只有1k大小,如果是,那么文件是符号链接,那么把文件重命名一下(备份)。
然后把g++-3.exe(或者g++-4.exe)拷贝一份,重命名为g++.exe。 把gcc-3.exe拷贝一份,重命名为gcc.exe。
试了一下,靠,根本不管用,这是哪门子方法,完全没逻辑性.
初步认为访问被拒绝是没有权限,于是右键点击g++.exe和gcc.exe,选择属性---安全,Domain User权限选择完全控制,果然好了.
看来网上的山寨方法确实很多,还要靠自己.
在android中使用了--start-group选项来链接依赖的静态库,比如
group_static_libs: true,为true的话会给static lib添加--start-group 属性,那么这个属性是做什么用的呢?
GCC解释如下:
--start-group archives --end-group
The archives should be a list of archive files. They may be either explicit file names, or -l options.
The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved.
Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.
通过上面的解释,默认的链接会根据名字先后顺序扫描一遍,可能会出现找不到定义的现象,如果定义--start-group archives --end-group的话,会多次循环直到找不到为止,也就是group里面没有定义位置,这样使用的话会带来性能的损失,但是在circular references 循环引用的情况就不会出现链接错误。
关于--start-group 在静态库中的使用看一下静态库和动态库的区别
静态库: 只编译不链接只是将.o通过ar命令集成到一个.a文件中
再看为什么使用--start-group ,如果A B两个.a相互调用的话,由于只是编译无链接,因此.a的生成可能是没有问题的,但是在.a链接中如果不使用--start-group可能会出现找不到定义的现象,使用--start-group可以避免这个现象发生
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)