title: /usr/bin/ld: attempted static link of dynamic object `/usr/lib64/libm.so'
body: <p>I'm not experienced at building with gcc at all and now require some help.
  I've a code that is being built with the following options </p>
  
  <pre><code>gcc \
      -g myCode.C \
      -O \
      -o myCode \
      -I. \
      -L. \
      -L/usr/lib64 \
      -lstdc++ \
      -Wreturn-type \
      -Wswitch \
      -Wcomment \
      -Wformat \
      -Wchar-subscripts \
      -Wparentheses \
      -Wpointer-arith \
      -Wcast-qual \
      -Woverloaded-virtual \
      -Wno-write-strings /usr/lib64/libm.so \
      -Wno-deprecated
  </code></pre>
  
  <p>When compiling <code>myCode.C</code> on redhat 6 machine it is not working on older versions of the OS throwing errors</p>
  
  <pre><code>/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
  /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found
  </code></pre>
  
  <p>To fix this issue, I've tried to add <code>-static</code> build option to make all dynamic linking libraries as static, but have some build error which i dont understand :(</p>
  
  <pre><code>/usr/bin/ld: attempted static link of dynamic object `/usr/lib64/libm.so'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>How do I make my code to work on older version of redhat rather than only on 6 and newer ?? what build options should I add/remove ?</p>