Embedded Cython UCS2 UCS4 issue

276 Views Asked by At

I have some python code I am trying to embed within c++ code using the cython api construct. For testing purposes I have been working off of: Example program of Cython as Python to C Converter

With the slightly modified code:

#foo.pyx
cdef public foo(double* x):
    x[0] = 0.0

//file.cpp
#include "Python.h"
#include "foo.h"
#include <iostream>

int main(int argc, const char * argv[])
{
    double arr[2] = {1,2};
    foo(arr);
    std::cout << arr[0] << std::endl;
    std::cout << arr[1] << std::endl;
}   

After running

cython foo.pyx

I attempt to compile receiving the error message:

foo.c:(.text+0x387): undefined reference to 'PyUnicodeUCS4_DecodeUTF8'

I have seen other questions regarding the matter, such as An UCS2-UCS4 incompatibility import failure of a Cythnized pure-Python module, and when I run:

import sys; sys.maxunicode

I get 1114111 which is in line with UCS4. So what I am wondering is how to I resolve this undefined reference, when my python version seems to be line with the proper UCS there, but not elsewhere.

1

There are 1 best solutions below

0
On

It turns out I had two different installations of python on my system and I was linking the wrong one.