嗨,我知道如何用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中导入