mac 下 swig用法

参考如下

    https://www.expobrain.net/2011/01/23/swig-tutorial-for-mac-os-x/

    http://www.swig.org/tutorial.html

 http://note.qidong.name/2018/01/hello-swig-example/

具体步骤:

swig -python -o example_wrap.c example.i

gcc -c -arch x86_64 example_wrap.c -o example_wrap.o -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7

ld -bundle -macosx_version_min 10.13 -flat_namespace \

-undefined suppress -o _example.so *.o


My environment:

High Sierra 10.13.4

Python2.7

// Xcode 9.3

// SWIG Version 3.0.12


其中-I and -L to tell gcc where the headers and libraries are on the file system.

可以通过 $(pkg-config --cflags --libs python2) 获得

如果 pkg-config --cflags --libs python2 无法执行

输入 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig

(https://github.com/sbinet/go-python/issues/28)

你可能感兴趣的:(mac 下 swig用法)