2017-06-07 58 views
1

我有一个我想在板上运行的python文件。因此,我想嵌入python解释器(用C语言编写)。我设法编写了单独的运行Python文件的C项目。它编译并按我的意愿运行。下面是相同的生成文件: -在TM4c1294XL中嵌入python解释器

CC=gcc 
CFLAGS=-I python3.5 -I config -I . -c -w 
LDFLAGS= -lpython3.5m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions 

all: classifier trainer test link 

test: 
    $(CC) $(CFLAGS) test.c 

trainer: Trainer.c 
    $(CC) $(CFLAGS) Trainer.c 
    $(CC) Trainer.o $(LDFLAGS) -o Trainer 

.ONESHELL: 
classifier: Classifier.c 
    $(CC) $(CFLAGS) Classifier.c 
    # $(CC) Classifier.o $(LLFLAGS) -o Classifier 

link: 
    $(CC) test.o Classifier.o $(LDFLAGS) -o test 

clean: 
    rm -f Trainer.o Trainer Classifier.o Classifier 

http://dpaste.com/3BCY2RE的项目我的整个目录“你好”(这是不是从例子中的一个)。

我列入 “Classifier.h” 我 “的hello.c” 和我收到以下错误:http://dpaste.com/3KKCF84

编译器的选项包括(无preincludes):

"${CG_TOOL_ROOT}/include" 
"${workspace_loc:/${ProjName}/TerrainPredict}" 
"${workspace_loc:/${ProjName}/TerrainPredict/config}" 
"${workspace_loc:/${ProjName}/TerrainPredict/python3.5}" 
"${SW_ROOT}/examples/boards/ek-tm4c1294xl" 
"${SW_ROOT}" 

连接文件的搜索路径:

"libc.a" 
"${workspace_loc:/${ProjName}/TerrainPredict/libterrainclf.a}" 
"${SW_ROOT}/driverlib/ccs/Debug/driverlib.lib" 

和:

"${CG_TOOL_ROOT}/lib" 
"${workspace_loc:/hello/TerrainPredict/libterrainclf.a}" 
"${CG_TOOL_ROOT}/include" 

我的一些配置有问题吗?或者这是python解释器的一些问题?任何帮助是极大的赞赏

编辑: - 作为@KevinDTimm建议,问题是有我的环境没有pyconfig.h。 python需要这个文件来定义重要的变量,如系统时钟源。我试图删除现有pyconfig.h中的安全检查。我得到的第一个错误是在pytime.h为:

"_PyTime_t need signed 64-bit integer type" 

进一步是因为下面的代码块:

#ifdef PY_INT64_T 
/* _PyTime_t: Python timestamp with subsecond precision. It can be used to 
    store a duration, and so indirectly a date (related to another date, like 
    UNIX epoch). */ 
typedef PY_INT64_T _PyTime_t; 
#define _PyTime_MIN PY_LLONG_MIN 
#define _PyTime_MAX PY_LLONG_MAX 
#else 
# error "_PyTime_t need signed 64-bit integer type" 
#endif 

在我看来,它需要一个用来存储时间的变量。我需要帮助分配该变量。

回答

1

From the linked problem

的multiarch错误消息是有点误导。这并不是失败,因为存在多元化问题,因为存在多操作系统问题,所以它失败了。 /usr/include/python*/pyconfig.h试图找出从哪里找到真正的pyconfig.h,并且因为它不知道,所以它正在救助。

您实际上需要为目标环境生成一个pyconfig.h。我不知道什么产生了pyconfig.h,也许从源码构建了cython? pyconfig.h看起来像是由gnu autoconf生成的东西,所以在生成它时不应该有任何大的问题。

+0

我想出了同一时间!如何获得TI板卡的pyconfig.h?有没有需要它的工作?如何写一个必须的? –

+0

对不起,但我没有答案 - 我知道问题是什么,但不是详细的解决方案 – KevinDTimm