I found a way to do this.
- I compiled and linked the code with g++.exe (For example
arm-linux-androideabi-g++.exe
). - For each compiled file I gave the following 2 switches
-fvisibility=hidden -s
both to compiler and to the linker. You need both switches. - No need to use
__attribute visibility
at all.