views:

248

answers:

2

I've literally spent the past half hour searching for the solution to this, and everything involves GCC. What I do here works absolutely fine with GCC, however I'm using TinyCC, and this is where I'm getting confused. First the code:

#include <Python.h>
#include <stdio.h>
int main(int argc, char*argv[])
{
    Py_Initialize();
    PyRun_SimpleString("print(\"Hello World!\")");
    Py_Finalize();
    return 0;
}

I then call tcc like so:

tcc -o tinypyembed.exe tiny.c -IC:\Python26\include -LC:\Python26\libs -lpython26

It then becomes a big fat jerk and spits out

tcc: undefined symbol 'Py_Initialize'
tcc: undefined symbol 'PyRun_SimpleStringFlags'
tcc: undefined symbol 'Py_Finalize'

I'm totally at my wits end and really do appreciate it if anyone knows what's up.

After asking a friend to try this out I have discovered that it is in fact a windows issue. May this stay here as a warning to anyone else who may try tinycc with python on windows.

+2  A: 

Did you use tiny_impdef.exe to create a .def file for the Python DLL?

bk1e
Well what do you know! :D Thank you so much :D
SAHChandler
So it was a link time error?
ojblass
+1  A: 

Full solution for Windows:

  1. tiny_impdef as per bk1e's advice

    tiny_impdef.exe c:\WINDOWS\system32\python25.dll

  2. add python25.def (or python26.def) to compilation list

    tcc tiny.c python25.def -IC:\Python25\include -LC:\Python25\libs -lpython25

    (replace 25 with 26 for Python2.6)

Slava N