从二进制文件中删除C ++类名 [英] Remove C++ class names from binary dll file
问题描述
CMyClass
。此类不会从dll或任何接口函数导出。但是,当我检查生成的dll文件时,存在一个字符串CMyClass。这是一个发布版本,我不希望这个字符串出现在dll文件中。这个dll是发送给客户的,我想让我在项目中使用的所有名字都被删除了dll文件,所以没有人可以得到这样一个简单的线索,我们在我们的dll中使用什么算法。 我使用版本配置。在项目属性中,链接器选项卡下的生成调试信息选项被关闭,C / C ++选项卡下的调试信息格式设置为程序数据库(/ Zi)。我试图为Debug Information Format设置空字符串,没有成功。
在dll中找到的字符串看起来像。AVCMyClass @@
并且位于dll文件的最后端。它是dll文件中唯一出现的CMyClass字符串。但是,这个字符串几乎是我所有的内部类。
如何摆脱这些提示?
更新
请注意,我不想让源代码本身模糊化。提供的链接是无关紧要的。我只是看不到为什么类名存储在dll文件中。我可以在构建之前重新命名我的课程,但是并不是非常简单的解决方案。
Update2
我不同意社区关闭这个quition,因为这不是重复的。答案由泰勒吉尔的评论发表。感谢他,对别人感到羞耻。
由于我的评论看来是正确的,我正在转发这个作为答案
类名的字符串是对已编译的二进制文件启用了RTTI(运行时类型信息)的结果。当启用RTTI时,编译器将创建存储有关编译到二进制文件中的类型的对象,其中一个属性是类型的名称。
请注意,某些用途 dynamic_cast
和 typeid
需要RTTI,因此禁用将会导致C ++的这些功能。
为了在Visual Studio中禁用RTTI,请使用 / GR -
开关(请参阅 http://msdn.microsoft.com/en-us/library/we6hfdy0(v = vs.100 ).aspx ,如Mikhail所发布的。)
要在GCC中禁用它,请使用 -fno-rtti
switch。
I have a C++ project under Visual Studio 2010 which compiles into a dll. I have several private implementation-specific classes defined in my project, e.g. CMyClass
. This class is not exported from the dll or by any interface function. However, when I check generated dll file, there is a string "CMyClass" stored in it. It is a release build, and I don't want this string to appear in the dll file. This dll is shipped to customers, and I want all names I used in my project to be stripped off the dll file, so nobody can get such a simple clue on what algorithms we use in our dll.
I use Release configuration. In project properties, the "Generate Debug Info" option under linker tab is turned off, the "Debug Information Format" under C/C++ tab is set to "Program Database (/Zi)". I tried to set empty string for "Debug Information Format" with no success.
The string found in the dll looks like .?AVCMyClass@@
and is located at the very end of the dll file. It is the only occurrence of the "CMyClass" string in the dll file. However, this string is presented for almost all my internal classes.
How to get rid of these mentions?
Update
Please note, I don't want to obfuscate the source code itself. The provided link is irrelevant. I just see no reason why class names are stored in the dll file. I can always rename my classes prior to build, but it is not very straight solution.
Update2
I don't agree with community on closing this qustion, since this is not a duplicate. And the answer is given in comments by Tyler Gill. Thanks to him and shame on others.
As my guess from a comment appears correct, I'm reposting this as an answer.
The string of the class name is a result of having RTTI (Runtime Type Information) enabled for the compiled binaries. When RTTI is enabled, the compiler creates objects that store information about the types compiled into the binary, one of whose properties is the name of the type.
Note that some uses of dynamic_cast
and typeid
require RTTI, so disabling will cost you those features of C++.
In order to disable RTTI in Visual Studio, use the /GR-
switch (see http://msdn.microsoft.com/en-us/library/we6hfdy0(v=vs.100).aspx, as Mikhail posted.)
To disable it in GCC, use the -fno-rtti
switch.
这篇关于从二进制文件中删除C ++类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!