I am creating a C ++ application that will call python + numpy, and I would like a DELAYLOAD python dll. I am using Visual Studio 2015 for Windows with 64-bit python 3.6. DELAYLOAD works fine until I use numpy. Once I call import_array() , I can no longer build using the DELAYLOAD option. Linker Error
LNK1194 cannot delay "python36.dll" due to import of data symbol "__imp_PyExc_ImportError"; link without /DELAYLOAD:python36.dll.
Here is my code:
// Initialize python Py_Initialize(); // If I remove this line, I am able to build with DELAYLOAD import_array();
Is there a way to make a possible delay when using numpy?
Alternative question: is it possible to create and populate numpy.recarray data without calling import_array ()?
EDIT: I decided to get rid of import_array (). Here are some of the code I use to initialize Python:
if (!Py_IsInitialized()) { // Initialize Python Py_Initialize(); // Initialize threads PyEval_InitThreads(); // Needed for datetime PyDateTime_IMPORT; // Needed to avoid use of Py_None, Py_True, and Py_False; // which cause inability to use DELAYLOAD HMODULE pythonDll = GetModuleHandle(L"python36.dll"); if (pythonDll == nullptr) { throw gcnew NotSupportedException(L"GS_ERR_CannotInitialize"); } PythonHelper::_pyNone = (PyObject*)GetProcAddress(pythonDll, "_Py_NoneStruct"); PythonHelper::_pyTrue = (PyObject*)GetProcAddress(pythonDll, "_Py_TrueStruct"); PythonHelper::_pyFalse = (PyObject*)GetProcAddress(pythonDll, "_Py_FalseStruct"); }
c ++ c python numpy visual-c ++
Andrey Belykh
source share