title: How to tell the MinGW linker not to export all symbols?
body: <p>I'm building a Windows dynamic library using the MinGW toolchain.</p>
  
  <p>To build this library I'm statically linking to other 2 which offer an API and I have a <code>.def</code> file where I wrote the only symbol I want to be exported in my library.</p>
  
  <p>The problem is that GCC is exporting all of the symbols including the ones from the libraries I'm linking to. Is there anyway to tell the linker just to export the symbols in the <code>def</code> file?</p>
  
  <p>I know there is the option <code>--export-all-symbols</code> but there seems not to be the opposite to it.</p>
  
  <p>Right now the last line of the build script has this structure:</p>
  
  <pre><code>g++ -shared CXXFLAGS DEFINES INCLUDES -o library.dll library.cpp DEF_FILE \
  OBJECT_FILES LIBS -Wl,--enable-stdcall-fixup
  </code></pre>
  
  <p>EDIT: In the <a href="http://tinyurl.com/27wkzb" rel="noreferrer">docs</a> about the linker it says that <code>--export-all-symbols</code> is the default behavior and that it's disabled when you don't use that option explicitly if you provide a <code>def</code> file, except when it doesn't; the symbols in 3rd party libs are being exported anyway.</p>
  
  <p>EDIT: Adding the option <code>--exclude-libs LIBS</code> or <code>–exclude-symbols SYMBOLS</code> doesn't prevent the symbols from the libraries from being exported.</p>