gpt4 book ai didi

macos - Mavericks : Compile Python Interpreter into a static lib

转载 作者:行者123 更新时间:2023-12-04 14:22:14 26 4
gpt4 key购买 nike

我要嵌入 Python 3.3 翻译成 Mac OS 10.9 cocoa 应用程序添加一些 Python 功能。根据我从另一个 StackOverflow 问答中读到的内容,最好创建一个静态库(页脚中的引用)而不是动态库。

这是我尝试从 Python 解释器中创建静态库(.a 文件)的内容:

  • 我已经从 here 下载了 Python 3.3 (CPython) 源代码.
  • 我已添加 *static*Modules/Setup.dist文件
  • 我已经输入以下内容来编译终端中的源代码:
  • ./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"

  • 我得到的结果如下:
    checking build system type... x86_64-apple-darwin13.1.0
    checking host system type... x86_64-apple-darwin13.1.0
    checking for --enable-universalsdk... no
    checking for --with-universal-archs... 32-bit
    checking MACHDEP... darwin
    checking for --without-gcc... no
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in `/Path/To/My/Source/Python-3.3.4':
    configure: error: C compiler cannot create executables
    See `config.log' for more details

    我的理解是 gcc 实际上被 Mavericks 中的 Apple LLVM 5.0 版(clang-500.2.79)(基于 LLVM 3.3svn)取代。

    另外,我在 中发现了以下内容配置日志 ...
    configure:3914: checking whether the C compiler works
    configure:3936: clang -static conftest.c >&5
    ld: library not found for -lcrt0.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    问题:如何使用 编译 Python 3.3苹果LLVM 所以我有一个静态库,比如 libpython3.3.a?

  • 引用文献1:
    Getting Python to work in Cocoa App
  • 引用文献2:
    Compile the Python interpreter statically?
  • 最佳答案

    我认为它默认构建一个静态库,在基于 Unix 的平台上,包括 OSX。也就是说,只是简单的配置,制作,制作安装。它对我有用并构建了 libpython3.4m.a。但是您可能会考虑使用 --prefix 并阅读有关在 OSX 上安装多个 Python 版本的信息。

    您引用的线程是旧的?

    Embedding 没有那么奇怪,否则 Python 文档和书籍不会深入讨论它。

    关于macos - Mavericks : Compile Python Interpreter into a static lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22273701/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com