title: How to probe the C++ ABI used by the system version of gcc on the target platform
body: <p>I have a configuration probe that determines what flags to pass to g++ based on platform and version. I typically use a later version of gcc than the native install version in order to gain access to C++14 features.
  On older platforms this means I need to add -D_GLIBCXX_USE_CXX11_ABI=0 to use the older C++ ABI or I cannot link with host versions of C++ libraries.
  However some newer platforms do use the new ABI in which case -D_GLIBCXX_USE_CXX11_ABI=1 (or nothing at all) is required.</p>
  
  <p>I can do this based on the version of the target platform (i.e. the output of lsb_release -a) but I would like a more general method.</p>
  
  <p>I think I'm half way there with compiling a C++ hello world program with the native compiler (as opposed to my later one) but I can't quite figure out how to probe the ABI version.
  E.g.</p>
  
  <pre>
  >strings hello | grep ABI
  .note.ABI-tag
  >strings hello | grep CXX
  GLIBCXX_3.4
  </pre>
  
  <p>or similarly on the version of libstdc++ used by the hello probe program.</p>
  
  <pre>
  ldd ./hello | grep stdc++ | sed -e 's_.* /_/_' | cut -f 1 -d' ' |xargs strings | grep 
  </pre>
  
  <p>Does anyone have any better suggestions?</p>
  
  <p><em>update:</em>
  In fact I don't need to do this at all. My real problem was that I had an older version of libstdc++.so hanging around. Compilation picked up one version 6.0.20 and the runtime picked up an incompatible one 6.0.19 (or possibly visa versa). I had an unresolved symbol which I incorrectly blamed on the ABI version. Contrary to popular belief minor versions of libstdc++ aren't always binary compatible. My intention is always to use the exact same version at run and compile time (if not using the host native one).</p>