title: exporting symbols in a dynamic qt library
body: <p>I'm trying to create a dynamic library using Qt on OS X 10.6.7 and Qt 4.7.3. I have created the most basic test I can think of (see below or <a href="https://gist.github.com/1016045" rel="nofollow noreferrer">https://gist.github.com/1016045</a>) and yet</p>
  
  <pre><code>otool -T build/libstackoverflow.dylib 
  </code></pre>
  
  <p>still reports</p>
  
  <pre><code>build/libstackoverflow.dylib:
  Table of contents (0 entries)
  module index symbol index
  </code></pre>
  
  <p>I'm assuming I should see something else in that list related to factorial.</p>
  
  <p>Test case (also at: <a href="https://gist.github.com/1016045" rel="nofollow noreferrer">https://gist.github.com/1016045</a>):</p>
  
  <pre><code>// main.cpp
  
  #include &lt;stdint.h&gt;
  #include &lt;QtCore/QtGlobal&gt;
  
  #if defined(MYSHAREDLIB_LIBRARY)
  #  define MYSHAREDLIB_EXPORT Q_DECL_EXPORT
  #else
  #  define MYSHAREDLIB_EXPORT Q_DECL_IMPORT
  #endif
  
  MYSHAREDLIB_EXPORT uint64_t factorial(int max) {
      int i           = max;
      uint64_t result = 1;
  
      while (i &gt;= 2)
          result *= i--;
  
      return result;
  }
  
  
  // stackoverflow.pro
  
  TEMPLATE = lib
  DEFINES += MYSHAREDLIB_LIBRARY
  CONFIG += qt dll
  TARGET = 
  DEPENDPATH += .
  INCLUDEPATH += .
  DESTDIR = ./build
  
  # Input
  SOURCES += main.cpp
  </code></pre>
  
  <p>To build:</p>
  
  <pre><code>qmake
  make
  </code></pre>
  
  <p>I've read: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2763259/creating-custom-qt-library">Creating Custom QT Library</a></li>
  <li><a href="http://developer.qt.nokia.com/doc/qt-4.7/sharedlibrary.html" rel="nofollow noreferrer">http://developer.qt.nokia.com/doc/qt-4.7/sharedlibrary.html</a></li>
  </ul>
  
  <p>Please recommend other resources if applicable!</p>
  
  <p>EDIT:</p>
  
  <p>I believe the symbols might be being exported correctly, although their names are mangled (or at least appear to be), which I thought using the Q_DECL_EXPORT macro was supposed to avoid. For example, here is the result of running nm -g build/libstackoverflow.dylib:</p>
  
  <pre><code>0000000000001f20 T __Z9factoriali
                   U ___gxx_personality_v0
                   U dyld_stub_binder
  </code></pre>
  
  <p>Is this what I should expect?</p>