ctypes找不到find dll函数

问题描述 投票:0回答:1

我是C ++的入门者,一直在尝试通过ctypes使用DLL从Python访问C ++函数。运行我的代码时,总是出现错误AttributeError: function 'my_function' not found

Header.h

#pragma once

int my_function(void);

Source.cpp

#include "Header.h"

int my_function(void)
{
    return(17); //test
}

ctypesTest.py

import ctypes

if __name__ == "__main__":

    mydll = ctypes.CDLL("MyDLL.dll")

    print(mydll.my_function())

每次运行Python脚本时,都会出现属性错误。

我只需要预期功能中的值。

python c++ dll ctypes
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.