[Numpy-discussion] embeding numpy in c++
Sunghwan Choi
sunghwanchoi91@gmail....
Wed Feb 27 23:30:26 CST 2013
Hi, I am now trying to embedding numpy in my c++ code (more correctly ase
module, which is dependent to numpy).
My test code is simple
test.cpp
#include "Python.h"
#include <stdio.h>
#include <iostream>
extern "C" void Py_Initialize();
extern "C" void PyErr_Print();
using namespace std;
int main(int argc, char* argv[])
{
double answer = 0;
PyObject *modname, *mod, *mdict, *func, *stringarg, *args, *rslt;
Py_Initialize();
modname = PyString_FromString("numpy");
mod = PyImport_Import(modname);
PyErr_Print();
cout << mod << endl;
return 0;
}
shchoi@aims0:~/tmp/test2$ vi test.cpp
shchoi@aims0:~/tmp/test2$ icpc -c test.cpp -I
~/program/epd/include/python2.7/
shchoi@aims0:~/tmp/test2$ icpc -o exe test.o -L ~/program/epd/lib/
-lpython2.7
shchoi@aims0:~/tmp/test2$ ./exe
Traceback (most recent call last):
File
"/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/__init__.py",
line 137, in <module>
import add_newdocs
File
"/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/add_newdocs.py",
line 9, in <module>
from numpy.lib import add_newdoc
File
"/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/lib/__init__.py"
, line 4, in <module>
from type_check import *
File
"/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/lib/type_check.p
y", line 8, in <module>
import numpy.core.numeric as _nx
File
"/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/core/__init__.py
", line 5, in <module>
import multiarray
ImportError:
/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/core/multiarray.s
o: undefined symbol: PyUnicodeUCS2_AsASCIIString
How to solve this problem? Can anyone help me?
If anyone know the solution, please let me know as soon as possible
Sincerely
Sunghwan Choi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130228/3e948405/attachment.html
More information about the NumPy-Discussion
mailing list