找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 3546|回复: 0

[求助] python 调用 vc++生成的 dll 中的函数,出错求助,谢谢

4

主题

5

帖子

5

积分

贫民

积分
5
hqs 发表于 2015-7-26 13:33:45 | 显示全部楼层 |阅读模式
// ----------------------------------------  MakeDll.h 代码如下 ----------------------------------------  
#define DLL_API __declspec(dllexport)
#include<iostream>
using namespace std;

DLL_API int add(int a, int b);
class DLL_API Point
{
private:
        float x, y;
public:
        Point();
};
// ----------------------------------------  MakeDll.cpp 代码如下 ----------------------------------------  
#include "stdafx.h"
#include <iostream>
using namespace std;
#include "MakeDll.h"

DLL_API int add(int a, int b)
{
        return a + b;
        cout << "a = " << a << "\tb = " << b << endl;
}
Point::Point()
{
        x = 0.0f;
        y = 0.0f;
        cout << "x = " << x << "\ty = " << y << endl;
}

# --------------------------------------- python 调用 dll 如下 ------------------------------------
from ctypes import *
api = CDLL('MakeDLL')
a = c_int(1)
b = c_int(2)
x = c_float(0.1)
y = c_float(1.2)
c = api.add(a,b)                      # 报错:AttributeError: function 'add' not found
p = api.Point(x,y)                     #报错:AttributeError: function 'Point' not found
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表