Building Python with VC8 on x64 Vista

danfike at gmail.com danfike at gmail.com
Thu Sep 20 10:45:51 EDT 2007


Hi all,

So I'm working on a C++ application that will eventually embed or
extend Python using Boost.Python, but I first need to get Python
compiled correctly for my platform. I've got a Windows Vista 64-bit
machine with a Core 2 processor, and I'm compiling with a VC8.

I downloaded the Python 2.5.1 source from python.org, and I opened the
Visual Studio solution file that was in the PCbuild8 directory. I
created a new x64 platform and managed to successfully compile the
'pythoncore' and 'python' projects (both in Debug and Release
configurations), resulting in working executables. (Aside: When
launched, the python console says "Python 2.5.1 [MSC v.1400 64 bit
(AMD64)] on win32" up top. Does that seem right?)

So, this program I'm writing with Boost.Python (that worked correctly
on x86 with home-built libraries) won't compile with these x64
libraries. I keep getting 'unresolved external symbols.' But, I'm
certain I'm linking in the library correctly. Here's a snippet from
the output (with /verbose:lib) when compiling:

1>Searching libraries
1>    <snip>
1>    Searching ..\..\..\3rdParty\boost_1_34_0\lib_x64\libboost_python-
vc80-mt-gy-1_34.lib:
1>    <snip>
1>    Searching ..\..\..\3rdParty\Python25\libs_x64\python25_d.lib:
1>Finished searching libraries
1>py_dyn_test.obj : error LNK2001: unresolved external symbol
_Py_NoneStruct
1>vector_py.obj : error LNK2001: unresolved external symbol
_Py_NoneStruct
1>volume_py.obj : error LNK2001: unresolved external symbol
_Py_NoneStruct
1>py_dyn_test.obj : error LNK2001: unresolved external symbol
_Py_RefTotal
1>vector_py.obj : error LNK2001: unresolved external symbol
_Py_RefTotal
1>volume_py.obj : error LNK2001: unresolved external symbol
_Py_RefTotal
1>volume_py.obj : error LNK2001: unresolved external symbol
PyExc_IndexError

If I switch to the Release configuration, I see fewer errors:

1>py_dyn_test.obj : error LNK2001: unresolved external symbol
_Py_NoneStruct
1>volume_py.obj : error LNK2001: unresolved external symbol
PyExc_IndexError

Note that none of my own code is Debug-specific. Also, the code in my
files is correct, because (as stated above), it worked fine for x86.

Though I don't know how useful it is, I did open the python libraries
in wordpad, and though most of the file wasn't legible, I did find
strings "Py_NoneStruct," "Py_RefTotal," and "PyExc_IndexError."


I suspect that I set up my "x64" platform configuration incorrectly,
or missed something. It's basically the same as the Win32
configuration, except with the /MACHINE:X64 flag instead of /
MACHINE:X86. One of the things I'm noticing just now, as I post this,
is that the preprocessor flag "WIN32" is still defined in the x64
configuration. Maybe if I change that to "WIN64," I'll have better
luck.

Any advice you have on what the "correct" way to do this is would be
appreciated.

-Dan




More information about the Python-list mailing list