【问题标题】:Python Build Problem on Mac OS 10.6 / Snow LeopardMac OS 10.6 / Snow Leopard 上的 Python 构建问题
【发布时间】:2011-01-13 18:14:42
【问题描述】:

我在 Snow Leopard 上遇到了 Python 2.6.4 的构建问题。

  • Mac OS X 10.6
  • Yonah CPU,32 位
  • gcc-4.2.1

更新我

通过从 CFLAGS 中删除所有非标准包含和库来解决(那里碰巧有一个 uuid/uuid.h ...)。尽管如此,它编译了尽管下面描述的错误,/usr/include/hfs/hfs_format.h:765 是一个热点。对于好奇或足智多谋的人,有问题的源文件:

$ cat /usr/include/hfs/hfs_format.h
...
748 #include <uuid/uuid.h>
749 
750 /* JournalInfoBlock - Structure that describes where our journal lives */
751 
752 // the original size of the reserved field in the JournalInfoBlock was
753 // 32*sizeof(u_int32_t).  To keep the total size of the structure the 
754 // same we subtract the size of new fields (currently: ext_jnl_uuid and
755 // machine_uuid).  If you add additional fields, place them before the
756 // reserved field and subtract their size in this macro.
757 //
758 #define JIB_RESERVED_SIZE  ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
759 
760 struct JournalInfoBlock {
761         u_int32_t       flags;
762         u_int32_t       device_signature[8]; // signature used to locate device.
763         u_int64_t       offset;        // byte offset to the journal on the device
764         u_int64_t       size;          // size in bytes of the journal
765         uuid_string_t   ext_jnl_uuid;
766         char            machine_serial_num[48];
767         char            reserved[JIB_RESERVED_SIZE];
768 } __attribute__((aligned(2), packed));
769 typedef struct JournalInfoBlock JournalInfoBlock;
...

我没有回答这个问题,因为构建产生了太多的警告和这个错误,仍然让我有点困惑......

更新二

为了摆脱关于部署目标的警告,我在编译前编辑了Makefile

$ cat Makefile
...
126 MACOSX_DEPLOYMENT_TARGET=10.3 # => 10.6
...

原始问题

在尝试从源代码构建 Python 2.6.4 时,我遇到了错误:

$ uname -v
$ Darwin Kernel Version 10.2.0: Tue Nov  3 10:37:10 PST 2009; \
    root:xnu-1486.2.11~1/RELEASE_I386

$ cd ~/src/Python-2.6.4
$ ./configure --enable-universalsdk=/ --prefix=$HOME
checking for --with-universal-archs... 32-bit
...
checking machine type as reported by uname -m... i386
...
checking for OSX 10.5 SDK or later... no   // <- But I have XCode + the SDKs installed?
...

$ make
...

...
/usr/include/hfs/hfs_format.h:765: error: \
    expected specifier-qualifier-list before ‘uuid_string_t’

它似乎植根于Python/mactoolboxglue.c。欢迎提示!


我也收到很多此类警告:

/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for \
Intel with Mac OS X Deployment Target < 10.4 is invalid.
gcc -c -arch ppc -arch i386 -isysroot /  -fno-strict-aliasing -DNDEBUG -g \
-fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include  \
-DPy_BUILD_CORE -o Objects/structseq.o  Objects/structseq.c
In file included from /usr/include/architecture/i386/math.h:626,
             from /usr/include/math.h:28,
             from Include/pyport.h:235,
             from Include/Python.h:58,
             from Objects/structseq.c:4:

【问题讨论】:

  • /usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for \ Intel with Mac OS X Deployment Target &lt; 10.4 is invalid. 这些错误是由 Python ./configure 脚本将 MACOSX_DEPLOYMENT_TARGET 默认设置为 10.3 引起的。请参阅我的答案以了解如何摆脱这些。
  • 在运行 ./configure 之前执行 export MACOSX_DEPLOYMENT_TARGET=10.6 而不是编辑 makefile。

标签: python macos gcc build 32-bit


【解决方案1】:

尝试将--universal-archs=32-bit 添加到configure 参数中。

编辑:您可能还需要设置环境变量 MACOSX_DEPLOYMENT_TARGET=10.6 并明确使用 10.6 SDK:

export MACOSX_DEPLOYMENT_TARGET=10.6
./configure --universal-archs=32-bit --enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk ...

在 10.6 上构建 Python 时仍然存在一些配置问题。如果您重新使用构建目录,请确保清除之前运行 configure 可能留下的所有缓存文件。

顺便说一句,如果您只需要 32 位版本,可以使用来自 python.org 的 2.6.4 OS X 安装程序。

【讨论】:

  • configure: error: unrecognized option: --dep-target=10.6 // 但是我在 Makefile 中找到了 MACOSX_DEPLOYMENT_TARGET=10.3 设置;改变了它,现在输出看起来好多了;再次感谢!
  • 对不起,我发的太匆忙了。 --dep-target 是安装程序构建脚本的参数,而不是配置。是的,在调用 configure 之前设置环境变量是正确的做法。确定答案。
【解决方案2】:

看来您不是唯一遇到此错误的人:

不确定这是否具有相同的根本原因:

http://trac.macports.org/ticket/21282

向下滚动到末尾的 cmets,这似乎表明了一个积极的结果。 (为方便起见,在此重复):

...//引自 trac.macports.org:

"尝试重命名、移动或删除 /opt/local/include/uuid/uuid.h" ...//结束引用

【讨论】:

    猜你喜欢
    • 2010-11-24
    • 1970-01-01
    • 2010-11-30
    • 2011-01-25
    • 2012-01-31
    • 1970-01-01
    • 2023-03-10
    • 2010-11-22
    • 1970-01-01
    相关资源
    最近更新 更多