Why does python3-config list -ldl before the last lined library?
<p>Running <code>python2.7-config --libs</code>, <code>python3.5-config --libs</code>, etc. results in the following output:</p>

<pre><code>-lpython&lt;version&gt; -lpthread -ldl -lutil -lm
</code></pre>

<p>Why isn't libdl the last linked library? I believe the order only matters when the preceding libraries reference the latter, but do neither libutil nor libm reference libdl, but libpthread does? I am unable to examine libpthread the way I normally might (readelf and/or nm) as it is apparently not in the right format.</p>

<p>Neither of the later libraries appear to reference libdl, so linking to libdl first is unnecessary. In fact, linking to libdl <em>first</em> appears to have no effect, nor does skipping it entirely.</p>

<pre><code>#include "Python.h"
int main(int argc, const char **argv) {}
</code></pre>

<p>...</p>

<pre><code>gcc -o main main.c `python3.5m-config --cflags` -lpython3.5m -lpthread -lutil -lm
</code></pre>

python