0

I created an example of a dynamic library in C++

#include <iostream>

extern "C" {
    void TaylorSeries(int x1, int x2, int delta_x, double E) {
        std::cout << x1 << x2 << std::endl;
    }
}

create from it dinamic library using commands "g++ -shared -fPIC -o lib.so lib.cpp" and "g++ -shared -o lib.dll lib.cpp" and then import to Python file

from ctypes import cdll

lib = cdll.LoadLibrary('./lib.so') 

lib.TaylorSeries(1, 3, 1, 1.0) 

I got an error

"lib.TaylorSeries(1, 3, 1, 1.0)  # Call the hello function from the library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 4: TypeError: Don't know how to convert parameter 4"

I don't know how to solve it because I'm working with dynamic libraries for the first time, please help

I have no idea how to make python understand the double type from C++

user_na
  • 2,154
  • 1
  • 16
  • 36
cherry_ds
  • 1
  • 2

0 Answers0