How to write a function in C ++ and integrate it in python


I started to study this issue. I am using swig. After assembling the interface file, I do not know how to use the written function in python. If there is a complete example, I will be grateful


On the Python side, it would look something like this:

import ctypes

# Подключение системных файлов
syslib = ctypes.cdll.msvcrt  # msvcrt.dll
syslib.printf(b"system DLL!\n")

# Подключение своих файлов
lib = ctypes.cdll.LoadLibrary("./NAME.dll")

# Вариант 2
lib2 = ctypes.CDLL("./NAME.dll")
x = lib2.SumData(5)

Dll implements the PrintData and SumData functions, SumData .

Scroll to Top