Extending and Embedding the Python Interpreter(五)

There are two more things to do before you can use your new extension: compiling and linking it with the Python system. If you use dynamic loading, the details may depend on the style of dynamic loading your system uses; see the chapters about building extension modules (chapter 3) and additional information that pertains only to building on Windows (chapter 4) for more information about this.

在使用我们的新扩展前我们还需要做两件事:编译和与python系统连接。如果你使用动态载入,那么细节将主要取决于你的系统动态载入的方式。

If you can't use dynamic loading, or if you want to make your module a permanent part of the Python interpreter, you will have to change the configuration setup and rebuild the interpreter. Luckily, this is very simple on Unix: just place your file (spammodule.c for example) in the Modules/ directory of an unpacked source distribution, add a line to the file Modules/Setup.local describing your file:

如果你不是使用动态载入,或者你希望你的模块成为python编译器永久的一部分,你需要改变的你的启动设置并且重新编译你的编译器。幸运的是,这项工作在Unix环境下非常简单:只要将spammodule.c文件放入Modules/ directory 目录,并且在Modules/Setup.local文件中加入一行来描述你的文件:

 

and rebuild the interpreter by running make in the toplevel directory. You can also run make in the Modules/ subdirectory, but then you must first rebuild Makefile there by running `make Makefile'. (This is necessary each time you change the Setup file.)

If your module requires additional libraries to link with, these can be listed on the line in the configuration file as well, for instance:

 

spam spammodule.o -lX11
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值