Reputation: 1442
I'm trying to compile a library that can be called from python using nvcc. Typically on windows I use the msys/mingw toolchain and can compile python extensions with no problem. However, when I try to compile using nvcc I believe it is using the link.exe which is (part of Microsoft Visual Studio). Although it compiles just fine, it fails at the link step.
I realize I'm using an old version of python (version 2.5). I'm working with a legacy application and I am stuck on with the old version for the time being.
Here's the nvcc command that I'm trying:
nvcc -I "C:\Python25\include" -I "C:\python25\Lib\site-packages\numpy\core\include\numpy" -L "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\lib\x64" -lcusolver -lcusparse -Xlinker "C:\Python25\libs\python25.lib" cusolve5.cu
But it fails with this message:
Creating library a.lib and object a.exp
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyObject_GetAttrString referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyCObject_AsVoidPtr referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyErr_SetString referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyErr_Format referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyArg_ParseTuple referenced in function main
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_Py_BuildValue referenced in function main
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_Py_InitModule4_64 referenced in function "void __cdecl initbmc(void)" (?initbmc@@YAXXZ)
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyErr_Print referenced in function "void __cdecl initbmc(void)" (?initbmc@@YAXXZ)
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyImport_ImportModule referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyCObject_Type referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyExc_AttributeError referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyExc_ImportError referenced in function _import_array
tmpxft_00001128_00000000-28_cusolve5.obj : error LNK2019: unresolved external symbol __imp_PyExc_RuntimeError referenced in function _import_array
a.exe : fatal error LNK1120: 13 unresolved externals
It appears to me that can't find the python library. With msys/mingw I can link a similar library like this:
g++ bmc.o -L "/c/python25/libs" -lpython25 -shared -o bmc.pyd
which works fine (but doesn't include any of the GPU acceleration I'm working on). My guess is there's some option I need to pass link.exe through the -Xlinker command, but I can't seem to find a way to include the python library while building.
Upvotes: 0
Views: 842
Reputation: 1442
Thanks to hints from @talonmies, I've concluded that what I'm trying to do is impossible for 2 reasons:
This could be resolved, though, by using ctypes to load the dll rather than a standard python import. However...
Upvotes: 1