如何禁用C ++死代码剥离在xcode中 [英] how to disable C++ dead code stripping in xcode

查看:269
本文介绍了如何禁用C ++死代码剥离在xcode中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图链接到所有未引用的符号从一些静态库(我自己的库)为我的C + + xcode应用程序。我已经尝试了所有与'strip'相关的属性(通过搜索'strip'的属性),但未引用的符号,特别是类没有链接。

I'm trying to link in all unreferenced symbols from a few static libraries (my own libraries) for my C++ xcode app. I have tried all the properties related to 'strip' (by searching the properties for 'strip'), but the unreferenced symbols, specifically classes, are not linked in.

我也尝试了-r链接器标志,但后来链接器只抱怨:
'ld:-r和-dead_strip不能一起使用'

I have also tried the -r linker flag, but then the linker only complains with: 'ld: -r and -dead_strip cannot be used together'

我已经尝试添加-no_dead_strip到链接器标志,但然后链接器只是告诉我
'-no_dead_strip'被忽略。

I have tried adding '-no_dead_strip' to the linker flags, but then the linker just tells me '-no_dead_strip' is ignored.

结果与'苹果LLVM'和'LLVM GCC'。

I get the same results with both 'Apple LLVM' and 'LLVM GCC'.

所以,我的问题是:我应该使用什么链接器标志或目标属性关闭所有死代码剥离和强制非引用的类链接在

So, my question is: what linker flag(s) or target properties should I use to switch off all dead code stripping and force unreferenced classes to be linked in?

推荐答案

标准链接机制 - 即使用 -l <​​/ code>选项链接 .a 文件将智能地过滤掉未使用的目标文件,因此不存在符号的原因

The standard linking mechanism - i.e. using the -l option to link a .a file will intelligently filter out object files that are not used, so the reason why the symbols are not present in the resultant binary is that they're not actually linked in.

如果你想从一个档案中获取所有的符号,你可以使用标志: -force_load libraryarchive ,使用像: -Wl,-force_load,libfoobar.a 其中 libfoobar.a 是要从中获取所有符号的归档文件。

If you want to get all the symbols from one archive, you can use the flag: -force_load libraryarchive, used like: -Wl,-force_load,libfoobar.a where libfoobar.a is the archive that you want to get all the symbols from.

为了获取所有归档文件中的所有符号,链接器标志: -all_load ,或者如果你从 gcc / / code> -Wl,-all_load

In order to get all the symbols from the all archives, you should use the linker flag: -all_load, or if you're driving it from gcc/clang the flag -Wl,-all_load.

它产生可怕的符号表!

It produces hideous symbol tables, though!

这篇关于如何禁用C ++死代码剥离在xcode中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆