I am trying to convert a c-style array in c++ to a numpy array and ran into problems when trying to use the "PyArray_SimpleNewFromData" function. It turns out I need to call
import_array()
Though I do not understand how to call this function. Whenever I try calling it I get compiler error which I do not manage to understand. For instance writing the following simple script:
#include <Python.h>
#include <numpy/arrayobject.h>
int main(){
Py_Initialize();
import_array();
Py_Finalize();
return 0;
}
produces the compiler error
error: return-statement with no value, in function returning 'int' [-fpermissive] import_array();
I looked at several examples, such as :
Numpy C-Api example gives a SegFault
PyArray_SimpleNewFromData example
https://codereview.stackexchange.com/questions/92266/sending-a-c-array-to-python-numpy-and-back
Numpy/CAPI error with import_array() when compiling multiple modules
But whatever I try (even when seemingly following those examples) I seem to run into the compiler error above. What am I missing or doing wrong? An explanation on how the import_array() function should be called would be very welcome. Thanks for the help!
Update:
I am using python 2.7.11, and I think it might be related to what is discussed here :
https://github.com/clemenscorny/brisk/issues/3
but I still have no idea how to fix it.