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)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容