問題描述
如何知道 libpython27.a 是 32 位還是 64 位? (How to know whether libpython27.a is 32‑bit or 64‑bit?)
我有一個 libpython27.a
文件:在 Windows 7 x64 上如何知道它是 32 位還是 64 位?
參考解法
方法 1:
Try dumpbin /headers "libpython27.a"
. (dumpbin reference)
The output will contain
FILE HEADER VALUES 14C machine (x86)
or
FILE HEADER VALUES 8664 machine (x64)
Note that if you get an error message like:
E:\temp>dumpbin /headers "libpython27.a"
LINK: extra operand `libpython27.a'
Try `LINK ‑‑help' for more information.
It means there is a copy of the GNU link utility somewhere in the search path. Make sure you use the correct link.exe
(e.g. the one provided in C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\bin
). It also requires mspdb80.dll
, which is in the same folder or something in PATH, otherwise you'll get the error message:
方法 2:
When starting the Python interpreter in the terminal/command line you may also see a line like:
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Where [MSC v.1500 64 bit (AMD64)] means 64‑bit Python.
Or
Try using ctypes to get the size of a void pointer:
import ctypes
print ctypes.sizeof(ctypes.c_voidp)
It'll be 4 for 32 bit or 8 for 64 bit.
方法 3:
On Linux you can use: objdump ‑a libpython27.a|grep 'file format'
.
Example:
f@f‑VirtualBox:/media/code$ objdump ‑a libpython27.a|grep 'file format'
dywkt.o: file format pe‑i386
dywkh.o: file format pe‑i386
dywks01051.o: file format pe‑i386
dywks01050.o: file format pe‑i386
dywks01049.o: file format pe‑i386
dywks01048.o: file format pe‑i386
[...]
(by Franck Dernoncourt、cgohlke、Kumar Saurabh、Franck Dernoncourt)