0
我有一些python代碼,我試圖嵌入到使用cython api構造的C++代碼中。出於測試目的,我已經工作過的: Example program of Cython as Python to C Converter嵌入式Cython UCS2 UCS4問題
隨着稍微修改代碼:
#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;
}
運行
cython foo.pyx
後,我試圖編譯收到錯誤消息:
foo.c:(.text+0x387): undefined reference to 'PyUnicodeUCS4_DecodeUTF8'
我看過其他questi附件關於此事,如An UCS2-UCS4 incompatibility import failure of a Cythnized pure-Python module,當我運行:
import sys; sys.maxunicode
我得到1114111這與UCS4線。所以我想知道的是如何解決這個未定義的引用,當我的python版本似乎與適當的UCS一致,但沒有其他地方。
你記得鏈接到Python嗎? –
我在我的生成文件中分別在我的CFLAGS和LDFLAGS中包含python-config --cflags和python-config --ldflags。 – someoneGeorge
我無法重現此問題。應該包含具有gcc(g ++)編譯和鏈接參數完整細節的[mcve]。 –