c++linker-errorslinker-flags

can't seem to find the linker I'm looking for linking objects under python.h


I have python3.4 and have installed python3-dev( I have directory at /usr/include/python3.4). I also have boost-python-dev installed.

To compile my cpp file, I'm using

g++ python-binding/struct.cpp -I /usr/include/python3.4 -I python-binding/src -lboost_python -lpython3.4

but my compiler can't seem to find -lpython3.4

/usr/bin/ld: cannot find -lpython3.4

I've also tired with -lpython3 -lpython -Python3.4 but none works.


Solution

  • You should be able to find the particular linking flags by utilizing pkg-config -- on my machine the invocation is pkg-config --libs python-3.4 (though my minimum version is 3.6 currently)

    the output will look something like this:

    $ pkg-config --libs python-3.6
    -lpython3.6m