[英]Why constructor still be exported when I using -fvisibility=hidden
I have a class A: 我有A班:
class A
{
public:
A() {}
virtual ~A() {}
void Func();
};
and another class M using A. I want to create libM.so which hidden all A's symbols. 和另一个使用A的类M。我想创建libM.so,它隐藏了所有A的符号。 I using the following script to compile it: 我使用以下脚本进行编译:
g++ -c A.cc -fPIC -fvisibility=hidden
g++ -c M.cc -fPIC
g++ -shared -z defs -o libM.so M.o A.o
But when I using "nm -DC libM.so", it still has 但是当我使用“ nm -DC libM.so”时,它仍然具有
0000000000000c78 W A::A()
0000000000000c78 W A::A()
I search this question on google and found another gcc option: "-fvisibility-inlines-hidden" to hidden inline functions, but I still got the same result even add this option when compile Ao 我在Google上搜索了此问题,发现了另一个gcc选项:“-fvisibility-inlines-hidden”到隐藏的内联函数,但是即使在编译Ao时添加此选项,我仍然得到相同的结果
g++ -c A.cc -fPIC -fvisibility=hidden -fvisibility-inlines-hidden
Why "-fvisibility-inlines-hidden" doesn't have effect? 为什么“ -fvisibility-inlines-hidden”不起作用? How do I prevent A::A() to appear in libM.so's export symbol? 如何防止A :: A()出现在libM.so的导出符号中? Thank you very much! 非常感谢你!
Thanks to Mike Seymour. 感谢Mike Seymour。 I should add -fvisibility-inlines-hidden when I compile M.cc 编译M.cc时,我应该添加-fvisibility-inlines-hidden
g++ -c A.cc -fPIC -fvisibility=hidden -fvisibility-inlines-hidden
g++ -c M.cc -fPIC -fvisibility-inlines-hidden
g++ -shared -z defs -o libM.so M.o A.o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.