I have a class 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. 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
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
g++ -c A.cc -fPIC -fvisibility=hidden -fvisibility-inlines-hidden
Why "-fvisibility-inlines-hidden" doesn't have effect? How do I prevent A::A() to appear in libM.so's export symbol? Thank you very much!
Thanks to Mike Seymour. I should add -fvisibility-inlines-hidden when I compile M.cc
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.