Yes. The command line utility is called python-config :
Usage: /usr/bin/python-config [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--help]
For snapping purposes, you must invoke it with the --ldflags . It will print a list of flags that you must pass to the linker (or g++ ) to associate with the python libraries installed on the system:
$ python-config --ldflags -L/usr/lib/python2.6/config -lpthread -ldl -lutil -lm -lpython2.6
It can also provide you with flags for compilation with the --cflags :
$ python-config --cflags -I/usr/include/python2.6 -I/usr/include/python2.6 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes
Say you have a test program in the test.cpp file, then you can do something like this to compile and link:
g++ $(python-config --cflags) -o test $(python-config --ldflags) ./test.cpp
This will link your program with shared libraries. If you want to be static, you can pass the -static option to the linker. But this will be related to all static things, including the runtime. If you want to go only with static python, you have to find these libraries yourself. One option is to parse the output of python-config --ldflags and search for libraries with .a extensions. But I would prefer to stick to all dynamic or all static.
Hope this helps. Good luck
user405725
source share