title: Undefined symbol: _ZN7QString13toUtf8_helperERKS_ at runtime
body: <p>I have two projects using Qt. One is being developed with QtCreator, the other with eclipse. Both use the same Qt 5.3.1 libraries, both are compiled with GCC. However, when I run the program that is in eclipse, it crashes with the message <code>Undefined symbol: _ZN7QString13toUtf8_helperERKS_</code>.</p>
  
  <p>A lookup showed that the code producing this error is</p>
  
  <pre><code>path.toStdString().c_str()     // path is a QString
  </code></pre>
  
  <p>and the exact location within qstring.h is</p>
  
  <pre><code>#if defined(Q_COMPILER_REF_QUALIFIERS) &amp;&amp; !defined(QT_COMPILING_QSTRING_COMPAT_CPP)
      QByteArray toLatin1() const &amp; Q_REQUIRED_RESULT
      { return toLatin1_helper(*this); }
      QByteArray toLatin1() &amp;&amp; Q_REQUIRED_RESULT
      { return toLatin1_helper_inplace(*this); }
      QByteArray toUtf8() const &amp; Q_REQUIRED_RESULT
      { return toUtf8_helper(*this); } //                 &lt;- here
      QByteArray toUtf8() &amp;&amp; Q_REQUIRED_RESULT
      { return toUtf8_helper(*this); }
      QByteArray toLocal8Bit() const &amp; Q_REQUIRED_RESULT
      { return toLocal8Bit_helper(constData(), size()); }
      QByteArray toLocal8Bit() &amp;&amp; Q_REQUIRED_RESULT
      { return toLocal8Bit_helper(constData(), size()); }
  </code></pre>
  
  <p>Converting a <code>QString</code> to <code>std::string</code> in the other project (the one in QtCreator) works just fine. What might be the problem? Are there any compiler options missing in eclipse?</p>
  
  <p><strong>Edit:</strong>
  The compiler outputs for sample files from the two projects are (I added line breaks for readability):</p>
  
  <p>Eclipse</p>
  
  <pre><code>Building file: ../src/mysource1.cpp
  Invoking: GCC C++ Compiler
  g++ -I"/home/username/myfolder/myproject1/src"
      -I"/home/username/myfolder/myproject1/src/dialogs"
      -I"/home/username/myfolder/myproject1/src/ignore"
      -I/usr/local/Qt-5.3.1/include -I/usr/local/Qt-5.3.1/include/QtCore
      -I/usr/local/Qt-5.3.1/include/QtGui -I/usr/local/Qt-5.3.1/include/QtWidgets
      -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -fPIE -MMD -MP
      -MF"src/mysource1.d" -MT"src/mysource1.d" -o "src/mysource1.o"
      "../src/mysource1.cpp"
  </code></pre>
  
  <p>QtCreator</p>
  
  <pre><code>g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB
      -DQT_CORE_LIB -I/usr/local/Qt-5.3.1/mkspecs/linux-g++ -I../myproject2 
      -I../myproject2/src -I../myproject2/src/data -I../myproject2/src/dialogs 
      -I../myproject2/src/widgets -I../myproject2/src/widgets/overlays
      -I../myproject2/src/widgets/tools -I/usr/local/Qt-5.3.1/include
      -I/usr/local/Qt-5.3.1/include/QtWidgets -I/usr/local/Qt-5.3.1/include/QtGui
      -I/usr/local/Qt-5.3.1/include/QtCore -I. -I. -o mainwind.o
      ../myproject2/src/mainwind.cpp
  </code></pre>
  
  <p><strong>Edit2:</strong>
  The linker outputs are as follows:</p>
  
  <p>Eclipse</p>
  
  <pre><code>Invoking: GCC C++ Linker
  g++ -L/usr/local/Qt-5.3.1/lib -o "myproject1" /*list of .o files*/
      -lQt5Core -lQt5Gui -lQt5Widgets -lgit2
  </code></pre>
  
  <p>QtCreator</p>
  
  <pre><code>g++ -Wl,-rpath,/usr/local/Qt-5.3.1/lib -o myproject2 /*list of .o files*/
      -L/usr/local/Qt-5.3.1/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
  </code></pre>