I am trying to make a static link with libpython2.7
on Mac OS X 10.11
.
While static-linking successfully worked with libpython2.7.a
in pyenv(anaconda)-build python
, it didn't work with libpython2.7.a
in Framework-build python
.
Creating static Mac OS X C build
Since it seems -static
option does NOT work on Mac OS X,
I tried the following.
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)
and got the following result.
$ 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)
Linking with libpython2.7.a
resulted in dynamic-linking with Versions/2.7/Python
.
I also found that both of libpython2.7.a
and libpython2.7.dylib
are the symbolic link to /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
Why there exists no valid static library for
libpython2.7
inFramework-build python
?What's the difference between
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
and a standard shared library?How can I make a static link with
libpython2.7
inFramework-build python
?