编写dylib_用python在mac import中创建dylib

嗨,我知道如何用visual studio 2012和c在windows中制作库(dll)++

在python中使用ctypes导入非常有效

这里有个小例子

在库.cpp在#define DLLEXPORT extern "C" __declspec(dllexport)

DLLEXPORT int sum(int a,int b)

{

return (a+b);

}

自由高度

^{pr2}$

在测试.py在from ctypes import *

mydll=cdll.LoadLibrary('lib.dll')

print mydll.sum(2,2)

我尝试用Xcode4.4版本在mac上运行相同的代码

当我在xcode中构建时,我得到了一个敌对的信息__declspec attribute 'dllexport' is not supported

什么时候进口库.dylib在python中我得到了错误AttributeError: dlsym(0x101afba30, sum): symbol not found

我做错了什么?

有人能写一个简单的代码吗,我如何在mac中用xcode使dylib正确地导入python2.6.4中的cypes

或者

are是在两个系统中导入python库的更好方法

为了麦克赢?在

basic我喜欢用visualstudio2012在windows中编写代码

然后在mac中用xcode进行简单的编译器,在python中导入

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值