如何在" OS X Framework-build python"

时间:2016-09-20 05:28:27

标签: python c++ macos gcc g++

我正在尝试在libpython2.7上与Mac OS X 10.11建立静态链接。

虽然静态链接在libpython2.7.a中与pyenv(anaconda)-build python成功配合使用,但它与libpython2.7.a中的Framework-build python无效。

Creating static Mac OS X C build

由于似乎-static选项在Mac OS X上不起作用, 我尝试了以下内容。

CXXFLAGS=-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
LIBS=/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.a

$ g++ -o main main.cc $(CXXFLAGS) $(LIBS)

并得到以下结果。

$ otool -L main
main:
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

libpython2.7.a关联导致与Versions/2.7/Python进行动态关联。

我还发现libpython2.7.alibpython2.7.dylib都是/System/Library/Frameworks/Python.framework/Versions/2.7/Python的符号链接。

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
-> ../../../Python

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.a
-> ../../../Python
  1. 为什么libpython2.7Framework-build python没有有效的静态库?

  2. /System/Library/Frameworks/Python.framework/Versions/2.7/Python与标准共享库之间的区别是什么?

  3. 如何在libpython2.7中与Framework-build python建立静态链接?

0 个答案:

没有答案