Is there any gcc/g++ linker flag than removes the hidden visibility from symbols of a shared library
<p>I went through this <a href="https://stackoverflow.com/questions/39348030/the-hidden-visibility-does-get-applied-in-my-shared-libraries-but-works-for-static">The hidden visibility does get applied in my shared libraries but works for static libraries on linux</a></p>
<p>and
<a href="https://stackoverflow.com/questions/36273404/is-there-any-way-to-override-the-fvisibility-hidden-at-link-time">Is there any way to override the -fvisibility=hidden at link time？</a></p>
<p>but I have follow up question</p>
<ol>
<li>File: <code>lib_mylib.h</code></li>
</ol>
<pre><code>int fun();
int fun1(void);
int fun2(void);
</code></pre>
<ol start="2">
<li>File: <code>lib_mylib.c</code></li>
</ol>
<pre><code>#include &lt;stdio.h&gt;
int fun() {
  return 2; 
}
int fun1(void) {
  return 2; 
}
int fun2(void) {
  return 2;
}
</code></pre>
<ol start="3">
<li>File: <code>my_lib_shared.c</code></li>
</ol>
<pre><code>#include &quot;my_lib.h&quot;
int foo(void) {
  return fun() + 4;
}
</code></pre>
<ol start="4">
<li>File: <code>my_lib_shared.h</code></li>
</ol>
<pre><code>int foo();
</code></pre>
<ol start="5">
<li>File driver.c</li>
</ol>
<pre><code>/* filename: driver.c  */
#include &quot;my_lib.h&quot;
#include &quot;my_lib_shared.h&quot;
#include &lt;stdio.h&gt;

int main() {
  int x = foo() ;
  return 0;
}
</code></pre>
<p>If I execute following steps</p>
<pre><code>1) `gcc -fPIC -fvisibility=hidden -c my_lib.c -o lib_mylib.o`
2) `gcc -fPIC -fvisibility=hidden -shared -o libMyLibHidden.so lib_mylib.o`
3) `gcc -fPIC -c my_lib_shared.c -o my_lib_shared.o`
4) `gcc -shared -o libMyShared2.so my_lib_shared.o`
5) `gcc -L. -Wall -o test_hidden driver.c -lMyLibHidden -lMyShared2`
</code></pre>
<p>the output of objdump is as</p>
<pre><code>objdump -T libMyLibHidden.so

libMyLibHidden.so:     file format elf64-x86-64

    DYNAMIC SYMBOL TABLE:
    0000000000000448 l    d  .init  0000000000000000       .init
    0000000000000000  w   D  *UND*  0000000000000000        __gmon_start__
    0000000000000000  w   D  *UND*  0000000000000000       _Jv_RegisterClasses
    0000000000000658 g    DF .fini  0000000000000000  Base  _fini
    0000000000000000  w   D  *UND*  0000000000000000     _deregisterTMCloneTable
    0000000000000000  w   D  *UND*  0000000000000000  _ITM_registerTMCloneTable
    0000000000000000  w   DF *UND*  0000000000000126   GLIBC_2.2.5 _cxa_finalize
    0000000000200938 g    D  *ABS*  0000000000000000  Base        __bss_start
    0000000000200948 g    D  *ABS*  0000000000000000  Base        _end
    0000000000200938 g    D  *ABS*  0000000000000000  Base        _edata
    0000000000000448 g    DF .init  0000000000000000  Base        _init
</code></pre>
<p>I did not any reference of functions of fun, fun1 and fun2 in the above objdump. Which is expected</p>
<p>and I get following error at final linking step</p>
<pre><code>/tmp/ccMsEpFq.o: In function main':
driver.c:(.text+0xe): undefined reference tofun' collect2: error: ld returned 1 exit status
</code></pre>
<p>but in my actual code and shared libraries of <code>libQtGui.so</code> i can see in my Makefile <code>-fvisibility=hidden</code> is given as flag but still the symbols are available in my dynamic symbol table of <code>libQtGui.so</code></p>
<p>=--------------------------------My question</p>
<p>is is there any flag in gcc linux or way where we can override the hidden visibility and make the symbols available in shared libraries</p>
<p>or there any flag in gcc linux where we can export all the symbols in the shared library</p>
<p>The flags of my Makefile while making shared library of <code>libQtGui.so</code> are</p>
<pre><code>CFLAGS        = -m64 -pipe -g -O2 -fvisibility=hidden -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS      = -m64 -pipe -fpermissive -g -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC $(DEFINES)
INCPATH       = -I../../mkspecs/linux-g++-64 -I. -I../../include/QtCore -I../../include/QtCore -I../../include -I../../include/QtGui -I../3rdparty/libpng -I../3rdparty/zlib -I/usr/include/freetype2 -I../3rdparty/harfbuzz/src -Idialogs -I.moc/release-shared -I/usr/X11R6/include -I.uic/release-shared
LINK          = g++

LFLAGS        = -m64 -Wl,-rpath/shared_libary_path -shared -Wl,-soname,libQtGui.so.4
</code></pre>