如何知道 libpython27.a 是 32 位還是 64 位? (How to know whether libpython27.a is 32-bit or 64-bit?)


問題描述

如何知道 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:

enter image description here

方法 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 DernoncourtcgohlkeKumar SaurabhFranck Dernoncourt)

參考文件

  1. How to know whether libpython27.a is 32‑bit or 64‑bit? (CC BY‑SA 2.5/3.0/4.0)

#32bit-64bit #Python #platform #static-libraries






相關問題

Visual Studio 將非託管 64 位 DLL 複製到 SysWOW64 而不是 System32 (Unmanaged 64-bit DLL copied to SysWOW64 and not System32 by Visual Studio)

將 R 包從 32 位安裝到 64 位 (install R package from 32bit to 64bit)

x32 ABI - гэта інструмент, як ім карыстацца (x32 ABI is this a tool ,how to use this)

在 64 位應用程序中使用 32 位 .lib 庫 (Using 32bit .lib library in a 64bit application)

當構建配置為“AnyCPU”或“x64”時,Castle Windsor 無法解決 (Castle Windsor not resolving when build configuration is "AnyCPU" or "x64")

32 位 SPARC V8 應用程序可以在 64 位 SPARC V9 上運行嗎? (Can 32-bit SPARC V8 application run on 64-bit SPARC V9?)

Eclipse 內存分析器:無法附加到 32 位進程 (Eclipse Memory Analyzer: Unable to attach to 32-bit process)

如何知道 libpython27.a 是 32 位還是 64 位? (How to know whether libpython27.a is 32-bit or 64-bit?)

確定當前進程是否在 WOW64 中運行或不在 Go 中運行 (Determining if current process runs in WOW64 or not in Go)

確保在 Windows Server 2003 64 位上安裝了 ASP.NET 3.5 Framework (Ensure that ASP.NET 3.5 Framework is installed on Windows Server 2003 64-bit)

為什麼我可以從在 IIS7 中以 64 位模式運行的 AnyCPU .NET Web 應用程序調用 32 位 COM 庫? (Why am I able to call a 32 bit COM library from an AnyCPU .NET web application running in IIS7 in 64 bit mode?)

編譯為 x86 時檢測 OS x86 或 x64 (Detect OS x86 or x64, when compiled as x86)







留言討論