views:

167

answers:

2

I have installed Python 3k(C:\Python30) and Visual Studio Professional Edition 2008.

I'm studying this.

Here is a problem:

C:\hello>dir
 Volume in drive C has no label.
 Volume Serial Number is 309E-14FB

 Directory of C:\hello

03/21/2009  01:15 AM    <DIR>          .
03/21/2009  01:15 AM    <DIR>          ..
03/21/2009  01:14 AM               481 hellomodule.c
               1 File(s)            481 bytes
               2 Dir(s)  10,640,642,048 bytes free


C:\hello>cl /LD hellomodule.c /Ic:\Python30\include c:\Python30\libs\python30.lib /link/out:hello.
dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

hellomodule.c
c:\hello\hellomodule.c(26) : warning C4716: 'inithello' : must return a value
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:hellomodule.dll
/dll
/implib:hellomodule.lib
/out:hello.dll
hellomodule.obj
c:\Python30\libs\python30.lib
   Creating library hellomodule.lib and object hellomodule.exp
hellomodule.obj : error LNK2019: unresolved external symbol _Py_InitModule referenced in function
_inithello
hello.dll : fatal error LNK1120: 1 unresolved externals

C:\hello>

What is the problem? Please, guide me.

+2  A: 

If Python is installed in c:\python30, why are you searching for the libraries in c:\Python24\libs\python30?

And now that you've changed the question to fix this :-),

I don't think Py_InitModule is available any more, you have to use PyModule_Create (this may have changed since the early betas of Py3k which is the last time I looked).

Based on your comments, David, I'd suggest you need to avoid the HowTo sites outside of the official Python docs (I suspect they're well out of date). There was a lot of work happening on the extension interface at the 3.0 level and the best place to look is either at the 3.0 docs or 3.1 alpha docs.

The specific Windows build instructions are here.

paxdiablo
Cool, It generated hello.dll, Now,How should I import it?(I tried import hello).But is says no module named hello.
TheMachineCharmer
NOTE: I just replaced Py_InitModule by PyModule_Create.Is that fine or do I need anything else.
TheMachineCharmer
A: 

as python 3.x why has chinese doc ?

I'm chinese , english is bad.... oh .... I'm like python. but.... chinese doc is too few for python 3.x

lcinx