I'm trying to create a little standalone executable to help troubleshoot a
problem on a windows system. The intent is not (necessarily) to have a fast
program, but rather to have a single .exe without a bunch of dll's, so we
don't have to copy more than one new file onto this production server.
Here's my (cygwin) Makefile:
CFLAGS=-Ic:/Python26/include
#LDFLAGS=-static -Lc:/Python26/libs -lpython26
LDFLAGS=-Lc:/Python26/libs -lpython26
CC=/cygdrive/c/MinGW/bin/gcc
PYTHON=/cygdrive/c/Python26/python
CYTHON=c:/Python26/Scripts/cython.py
V=python26
#CFLAGS=-Ic:/Python26/include
#LDFLAGS=-static -L. -lpython26
##LDFLAGS=-L. -lpython26
#CC=/cygdrive/c/MinGW/bin/gcc
#PYTHON=/cygdrive/c/Python26/python
#CYTHON=c:/Python26/Scripts/cython.py
#V=python26
#lib$V.a: /cygdrive/c/Python26/libs/$V.lib
# "$(HOME)/bin/pexports" c:/Python26/libs/$V.dll > $V.def
# dlltool --dllname $V.dll --def $V.def --output-lib lib$V.a
seconds.exe: seconds.o # lib$V.a
$(CC) $(LDFLAGS) -o seconds.exe seconds.o
seconds.o: seconds.c
$(CC) -c $(CFLAGS) seconds.c
seconds.c: seconds.pyx
$(PYTHON) $(CYTHON) --embed seconds.pyx
clean:
rm -f *.o *.exe *.c
Things are OK until the link is attempted, at which point I get:
/cygdrive/c/MinGW/bin/gcc -Lc:/Python26/libs -lpython26 -o seconds.exe
seconds.o
seconds.o:seconds.c:(.text+0x6f): undefined reference to
`_imp__PyInt_FromLong'
seconds.o:seconds.c:(.text+0x124): undefined reference to
`_imp__PyTuple_New'
seconds.o:seconds.c:(.text+0x1b8): undefined reference to
`_imp__Py_InitModule4'
seconds.o:seconds.c:(.text+0x200): undefined reference to
`_imp__PyImport_AddMod
ule'
seconds.o:seconds.c:(.text+0x253): undefined reference to
`_imp__PyObject_SetAtt
rString'
seconds.o:seconds.c:(.text+0x2a5): undefined reference to
`_imp__PyObject_SetAtt
rString'
It goes on like that for quite a while, about a bunch of _imp__ functions
being missing.
Do I need to build my program with the same C compiler that my Python
distribution was built with?
I saw the FAQ about needing to build a libpython26.a, but 1) I have one
already, and 2) pexports errored. I also googled quite a bit and didn't
find anything that looked quite relevant.
I'm using Python 2.6.4 from python.org on Windows XP SP3, Dave Cournapeau's
Cython 0.11.2 installer for Python26, and MinGW (native gcc) 5.1.6. I'm
using Cygwin make, but the rest is intended to be non-cygwin (though if a
static cygwin executable will run without cygwin, that might work for me
too).
BTW, does distutils support building a --embed executable?
Any suggestions?
TIA!
--
Dan Stromberg
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev