When I try to embed python code in C, I compile it, using command: gcc -o embed_python $(python-config) embed_python.c However python-config returns bad compiler flags and linker fails to build executable. I've managed to create a workaround (see Additional Information). Reproducible: Always Steps to Reproduce: 1.Copy this C source to a file embed_python.c #include <stdio.h> #include <python2.4/Python.h> int main(int argc, char **argv) { Py_Initialize(); PyRun_SimpleString("print 'Hello World!'"); Py_Finalize(); return 0; } 2.Try to compile it, using: gcc -o embed_python $(python-config) embed_python.c 3.Optionally, get my sample programs from http://venus.wsb-nlu.edu.pl/~kwalo/embed_python.tar.gz unpack it and type `make'. It shouldn't compile, by default :) Actual Results: I get this output from python-config command: -lpython2.4 -lm -L/usr/lib/python2.4/config Additionally, python throws this Exception: Traceback (most recent call last): File "/usr/bin/python-config-2.4.orig", line 3, in ? print "-lpython2.4 -lm -L/usr/lib/python2.4/config",string.join(string.split(distutils.sysconfig.get_config_var("MODLIBS"))) File "/usr/lib/python2.4/string.py", line 292, in split return s.split(sep, maxsplit) AttributeError: 'NoneType' object has no attribute 'split' Such flags passed to compiler, cause liker not to build executable. Output from the compiler: /tmp/ccYDv0yc.o: In function `main': bug_demo.c:(.text+0x12): undefined reference to `Py_Initialize' bug_demo.c:(.text+0x1e): undefined reference to `PyRun_SimpleString' bug_demo.c:(.text+0x23): undefined reference to `Py_Finalize' collect2: ld returned 1 exit status Expected Results: Output of python-config command, should return proper gcc flags. In my case, these are: -lpython2.4 -lm Running for example: gcc -o embed_python $(python-config) embed_python.c should create an executable. I fixed this problem, by replacing contents of /usr/bin/python-config-2.4, with the following file: #!/usr/bin/python print "-lpython2.4 -lm" With these flags, my sample C program compiles correctly.
*** This bug has been marked as a duplicate of bug 188029 ***