python导入dll_无法在python中导入自定义DLL

我试图用^ {< CD1>}将一个C++类暴露给Python,所以我要通过this tutorial。我用以下源代码创建了一个visual studio .dll项目:#include using namespace boost::python;struct World{void set(std::string msg) { this->msg = msg; }std::stri...
摘要由CSDN通过智能技术生成

我试图用^ {< CD1>}将一个C++类暴露给Python,所以我要通过this tutorial。我用以下源代码创建了一个visual studio .dll项目:#include

using namespace boost::python;

struct World

{

void set(std::string msg) { this->msg = msg; }

std::string greet() { return msg; }

std::string msg;

};

BOOST_PYTHON_MODULE(hello)

{

class_("World")

.def("greet", &World::greet)

.def("set", &World::set)

;

}

我把它构建成一个64位的dll。本教程的下一步是:Here, we wrote a C++ class wrapper that exposes the member functions greet and set. Now, after building our module as a shared library, we may use our class World in Python. Here's a sample Python session:

^{pr2}$

但是,在同一目录中启动python并键入import hello之后,我得到>>> import hello

Traceback (most recent call last):

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值