I am trying to integrate C++ function which calculates tan hyperbolic function found in this incredibly useful link https://learn.microsoft.com/en-us/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019
However, when I tried to follow the steps as mentioned in the link, I am getting error. The code in C++ is as follows
#include <Windows.h>
#include <cmath>
#include <pybind11/pybind11.h>
#include <Python.h>
const double e = 2.7182818284590452353602874713527;
double sinh_impl(double x) {
return (1 - pow(e, (-2 * x))) / (2 * pow(e, -x));
}
double cosh_impl(double x) {
return (1 + pow(e, (-2 * x))) / (2 * pow(e, -x));
}
double tanh_impl(double x) {
return sinh_impl(x) / cosh_impl(x);
}
int main() {
return 0;
}
namespace py = pybind11;
PYBIND11_MODULE(superfastcode22, m) {
m.def("fast_tanh2", &tanh_impl, R"pbdoc(
Compute a hyperbolic tangent of a single argument expressed in
radians.
)pbdoc");
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}
I am getting error at PYBIND11_MODULE while trying to build the .pyd output of the above C++ code. The error mainly tells
incomplete types not allowed
I have tried to follow the exact steps mentioned in the above web page.
However, I was having little difficulty while installing pybind11 libraries (I couldn't properly run pip install pybind11 due to timeout and access being denied to install pybind libraries), so I just downlaoded the library files and copy pasted into the python include directory. Can it be one of the reason? Maybe some of the dependencies might be missing which I would have had obtained if I did pip install pybind11? If so, then I might have to replace pybind11 with CPython.