C++ Makefiles: What is the equivalent of -lpython2.7 for python 3.9 (ie where is the python3 library?)

Viewed 49

I am trying to compile some c++code that uses matplotlibcpp and I am having quite a difficult time. In my makefile, I am following the example on the matplotlibcpp documentation and adding a -lpython3.9 flag (I am using python 3.9 because my macs python2.7 doesnt allow me to link -lpython2.7). When I try to compile I get an error stating:

""ld: library not found for -lpython3.9"

I would like to know what the correct library name I need to use is so I can have access to python 3.9.

For context I am using clang++ and python 3.9 installed using homebrew

PS: I searched in my Versions/3.9/lib folder and it has a file called "libpython3.9.dylib" which seems like it might be what I want but I dont know how to include it that same way I would -lpython3.9.

1 Answers

What is the equivalent of -lpython2.7 for python 3.9 (ie where is the python3 library?)

It doesn't have much to do either with C++ or with makefiles, but with a conventional Python 3.9 installation, the analogue of -lpython2.7 is -lpython3.9.

When I try to compile I get an error stating:

""ld: library not found for -lpython3.9"

That is almost certainly a sign that the library is outside the applicable library search path, not that you have an inappropriate -l option. You would typically resolve that by using an -L/path/to/directory/of/libpython option earlier on the command line.

Related