Jun-16-2022, 05:56 AM
Hello,
I want to use some c++ library in python code.
I used scipy dsp(digital signal processing) filter until now, but it was too slow and this part became a bottle neck of my code.
So I'm trying to change it to another c++ library to reduce filtering time.
(Under windows 10, python 3.7.6 32bit environment)
For example, I wanted to use dsp c++ library: https://github.com/berndporr/iir1
(or boost low pass filter. I'll try it later.)
so I'm trying to wrap the code using this libary written in c++ to make pyd as below (LPFtest.cpp).
LPFtest.obj : error LNK2001: unresolved external symbol "public: __thiscall Iir::ChebyshevI::AnalogLowShelf::AnalogLowShelf(void)" (??0AnalogLowShelf@ChebyshevI@Iir@@QAE@XZ)
LPFtest.obj : error LNK2001: unresolved external symbol "public: __thiscall Iir::ChebyshevI::AnalogLowPass::AnalogLowPass(void)" (??0AnalogLowPass@ChebyshevI@Iir@@QAE@XZ)
...more error LNK2001 and
build\lib.win32-3.7\LPFtest.cp37-win32.pyd : fatal error LNK1120: 19 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120
Should I include or let this code know where is dll or lib file?
Please let me know if you have any idea, or further information.
Thank you in advance!
Best wishes,
JESuh
I want to use some c++ library in python code.
I used scipy dsp(digital signal processing) filter until now, but it was too slow and this part became a bottle neck of my code.
So I'm trying to change it to another c++ library to reduce filtering time.
(Under windows 10, python 3.7.6 32bit environment)
For example, I wanted to use dsp c++ library: https://github.com/berndporr/iir1
(or boost low pass filter. I'll try it later.)
so I'm trying to wrap the code using this libary written in c++ to make pyd as below (LPFtest.cpp).
#include <Python.h> #include ".\iir1\Iir.h" #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include "path\numpy\core\include\numpy\ndarraytypes.h" #include "path\numpy\core\include\numpy\ndarrayobject.h" #include "path\numpy\core\include\numpy\arrayobject.h" int test() { printf("Hi"); // I'll put my code here to use IIR filter from iir1 library return 0; } static PyObject* ctest(PyObject* self, PyObject* args) { int reply = test(); // this part of code also will be changed if I can use iir1 library.. return Py_BuildValue("i", reply); } static PyObject* version(PyObject* self) { return Py_BuildValue("s", "Version 0.1"); } static PyMethodDef myMethods[] = { {"test", ctest, METH_VARARGS, "test LPF"}, {"version", (PyCFunction)version, METH_NOARGS, "return the version."}, {NULL, NULL, 0, NULL} }; static struct PyModuleDef LPFtest = { PyModuleDef_HEAD_INIT, "LPFtest", "test", -1, myMethods }; PyMODINIT_FUNC PyInit_LPFtest(void) { return PyModule_Create(&LPFtest); }and made setup.py as below.
from distutils.core import setup, Extension module = Extension("LPFtest", sources = ["LPFtest.cpp"]) setup(name = "LPFtest", version = "0.1", description = "LPFtest", ext_modules = [module])However, if I executed setup.py as python setup.py build, it shows me a following linker error.
LPFtest.obj : error LNK2001: unresolved external symbol "public: __thiscall Iir::ChebyshevI::AnalogLowShelf::AnalogLowShelf(void)" (??0AnalogLowShelf@ChebyshevI@Iir@@QAE@XZ)
LPFtest.obj : error LNK2001: unresolved external symbol "public: __thiscall Iir::ChebyshevI::AnalogLowPass::AnalogLowPass(void)" (??0AnalogLowPass@ChebyshevI@Iir@@QAE@XZ)
...more error LNK2001 and
build\lib.win32-3.7\LPFtest.cp37-win32.pyd : fatal error LNK1120: 19 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120
Should I include or let this code know where is dll or lib file?
Please let me know if you have any idea, or further information.
Thank you in advance!
Best wishes,
JESuh