title: A "how is it finding libpython?!" puzzle
body: <p>I'm trying to get a semi-abandoned python scientific computing package written for python 2 to compile against python 3.  My problem has to do with the linker not being able to find libpython. It's obvious why it can't find libpython from the g++ command line; what I don't get is why it works in the python 2.7 case and not in the python 3.6 case.</p>
  <p>This works:</p>
  <pre><code>g++ -pthread -shared -fopenmp src/matrix/Matrix.o src/matrix/Statistics.o -L/usr/lib/python2.7/dist-packages -lpython2.7 -o condensedMatrix.so
  </code></pre>
  <p>This doesn't work:</p>
  <pre><code>g++ -pthread -shared -fopenmp src/matrix/Matrix.o src/matrix/Statistics.o -L/usr/lib/python3/dist-packages -lpython3.6 -o condensedMatrix.so
  /usr/bin/x86_64-linux-gnu-ld: cannot find -lpython3.6
  </code></pre>
  <p><em>Neither</em> should work because the respective paths to libpython:</p>
  <pre><code>-L/usr/lib/python2.7/dist-packages
  -L/usr/lib/python3/dist-packages
  </code></pre>
  <p>are both incorrect:  This is an Ubuntu 18.04 system, so the libraries in question can be found here:</p>
  <pre><code>/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
  /usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so
  </code></pre>
  <p>In the python 2.7 case, which compiles, I don't have an LD_LIBRARY_PATH set; however setting LD_LIBRARY_PATH to point to the correct location for libpython3.6.so doesn't help.</p>
  <p>The build system used here is <strong>build.py</strong>.  I'm trying to figure out where it's getting the <code>-L/usr/lib/python*/dist-packages</code> directive in the g++ compile line, but meanwhile the real mystery is why the python 2.7 case compiles.</p>
  <p>Anyone know what's going on here?</p>