John P John P - 1 year ago 50
Python Question

Why does python3-config list -ldl before the last lined library?


python2.7-config --libs
python3.5-config --libs
, etc. results in the following output:

-lpython<version> -lpthread -ldl -lutil -lm

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.

Answer Source

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

#include "Python.h"
int main(int argc, const char **argv) {}


gcc -o main main.c `python3.5m-config --cflags` -lpython3.5m -lpthread -lutil -lm
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download