【问题标题】:How to know whether libpython27.a is 32-bit or 64-bit?如何知道 libpython27.a 是 32 位还是 64 位?
【发布时间】:2015-11-13 06:08:44
【问题描述】:

我有一个libpython27.a 文件:在 Windows 7 x64 上如何知道它是 32 位还是 64 位?

【问题讨论】:

    标签: python static-libraries 32bit-64bit platform


    【解决方案1】:

    试试dumpbin /headers "libpython27.a"。 (dumpbin reference)

    输出将包含

    FILE HEADER VALUES 14C machine (x86)

    FILE HEADER VALUES 8664 machine (x64)


    请注意,如果您收到如下错误消息:

    E:\temp>dumpbin /headers "libpython27.a"
    LINK: extra operand `libpython27.a'
    Try `LINK --help' for more information.
    

    这意味着在搜索路径的某处有一份 GNU 链接实用程序的副本。确保您使用正确的link.exe(例如C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\bin 中提供的那个)。它还需要mspdb80.dll,它在同一个文件夹或PATH中的某个东西中,否则你会收到错误消息:

    【讨论】:

      【解决方案2】:

      在终端/命令行中启动 Python 解释器时,您可能还会看到如下行:

      Python 2.7.2(默认,2011 年 6 月 12 日,14:24:46)[MSC v.1500 64 位 (AMD64)]在win32上

      其中 [MSC v.1500 64 位 (AMD64)] 表示 64 位 Python。

      或者

      尝试使用 ctypes 获取 void 指针的大小:

      import ctypes
      print ctypes.sizeof(ctypes.c_voidp)
      

      32 位为 4,64 位为 8。

      【讨论】:

        【解决方案3】:

        在 Linux 上,您可以使用:objdump -a libpython27.a|grep 'file format'

        例子:

        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
        [...]
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-08-08
          • 2011-04-19
          • 2012-03-17
          • 2017-09-13
          相关资源
          最近更新 更多