logo       

Re: successfully using gcc to generate extensions for windows: msg#00033

python.pyrex

Subject: Re: successfully using gcc to generate extensions for windows

Success at last !

>>> import primes
>>> primes.primes(10)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

I renamed the "mymodules" to "primes" in setup.py
*and* used the following line fromt he command line :

D:\Python Projects\c>setup.py build_ext --compiler=mingw32
running build_ext
building 'primes' extension
writing build\temp.win32-2.3\Release\primes.def
F:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.3\Release\primes.
o build\temp.win32-2.3\Release\primes.def -LD:\Python23\libs -LD:\Python23\PCBui
ld -lpython23 -o build\lib.win32-2.3\primes.pyd

D:\Python Projects\c>

I tried the command line option first and it failed - but I noticed the presence of errors mentioning 'mymodules' -(which I assumed was just an output name for the module) - so I renamed.... and it succeeded. I'll try it again with disutils.

Hmm... just have - still get the Visual Studio 6 needed error.................
So it looks like disutils *isn't* picking up my disutils.cfg.........

Oh well..........

Thanks for your help guys.

I look forward to trying some more interesting stuff over the weekend.

Regards,


Fuzzy


Voidspace wrote:



Phillip J. Eby wrote:

At 08:54 AM 4/16/04 +0100, Voidspace wrote:

In actual the reply from Greg might contain the answer to my further difficulties :-)

However - below are the resutls of my *failed* experiments last night.............

I thought I'd followed the instructions in :
http://randomthoughts.vandorp.ca/syncato/WK/blog/758_Simple_instructions_to_compile_python_C_extensions_in_windows.item
to the letter !
(Thanks for the replies by the way - both Phillip and Greg).

Now the 'random thoughts' page says that after installing MinGW successfully and adding a disutils.cfg file (which didn't exist already).... I ought to be able to compile extensions from disutils automagically.................

However it seems that maybe :

python setup.py build_ext --compiler=mingw32

is the right way instead.... (I'll try it when I get home)



Where did you put the distutils.cfg? It has to go in your Python2X\Lib\distutils directory. Mine looks like this:

[build]
compiler=mingw32

If you have that in place, you should never need the --compiler flag. In the two years I've had that file, I've never needed --compiler or -c.

Second, did you actually build a 'libpython2x.a' file? You didn't mention that. If you didn't do that, you're not going to be able to actually build a .pyd. See step 2 on this page:

http://sebsauvage.net/python/mingw.html


(By the way, whenever I refer to "python2x" I mean e.g. python22 or python23, as appropriate for what version you're using.)


F:\Python Projects\c>gcc -shared primes.o -o primes.so



That won't work. Windows uses '.pyd' files, not '.so' files. And, you've got no -L here to specify where your libpython is at.


Can you tell me what the correct gcc incantion would be to generate a .pyd I guestimated with the following result.:

D:\Python Projects\c>gcc -shared primes.o -L D:\Python23\libs\libpython23.a -o
primes.pyd
primes.o(.text+0x5f):primes.c: undefined reference to `_imp__PyArg_ParseTupleAnd
Keywords'
primes.o(.text+0x7c):primes.c: undefined reference to `_imp___Py_NoneStruct'
primes.o(.text+0x94):primes.c: undefined reference to `_imp__PyList_New'
primes.o(.text+0x1f5):primes.c: undefined reference to `_imp__PyObject_GetAttrSt
ring'
primes.o(.text+0x22f):primes.c: undefined reference to `_imp__PyInt_FromLong'
primes.o(.text+0x268):primes.c: undefined reference to `_imp__PyTuple_New'
primes.o(.text+0x2c4):primes.c: undefined reference to `_imp__PyObject_CallObjec
t'
primes.o(.text+0x4e3):primes.c: undefined reference to `_imp__Py_InitModule4'
primes.o(.text+0x4fa):primes.c: undefined reference to `_imp__PyImport_AddModule
'
primes.o(.text+0x51d):primes.c: undefined reference to `_imp__PyObject_SetAttrSt
ring'
primes.o(.text+0x5a2):primes.c: undefined reference to `_imp__PyString_FromStrin
g'
primes.o(.text+0x5c0):primes.c: undefined reference to `_imp__PyString_FromStrin
g'
primes.o(.text+0x5e1):primes.c: undefined reference to `_imp__PyModule_GetDict'
primes.o(.text+0x5fe):primes.c: undefined reference to `_imp__PyTuple_New'
primes.o(.text+0x61e):primes.c: undefined reference to `_imp__PyString_FromStrin
g'
primes.o(.text+0x662):primes.c: undefined reference to `_imp__PyCode_New'
primes.o(.text+0x682):primes.c: undefined reference to `_imp__PyThreadState_Get'

primes.o(.text+0x68d):primes.c: undefined reference to `_imp__PyFrame_New'
primes.o(.text+0x6b4):primes.c: undefined reference to `_imp__PyTraceBack_Here'

D:\Python Projects\c>














--

http://www.Voidspace.org.uk The Place where headspace meets cyberspace. Online resource site - covering science, technology, computing, cyberpunk, psychology, spirituality, fiction and more.
---
http://www.atlantibots.org.uk
http://groups.yahoo.com/group/atlantis_talk/
Atlantibots - stomping across the worlds of Atlantis.
Building with Python - programming language that rules the world.
---
http://www.fuchsiashockz.co.uk http://groups.yahoo.com/group/void-shockz
---

Everyone has talent. What is rare is the courage to follow talent
to the dark place where it leads. -Erica Jong
Ambition is a poor excuse for not having sense enough to be lazy.
-Milan Kundera


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise