【发布时间】:2017-06-07 12:53:49
【问题描述】:
我有一个要在板上运行的 python 文件。因此,我想将 python 解释器(用 C 编写)嵌入板中。我设法编写了运行 Python 文件的单独 C 项目。它可以按我的意愿编译和运行。这是相同的makefile:-
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 是我的项目“hello”的整个目录(它不是示例中的目录)。
我在“hello.c”中包含“Classifier.h”,但出现以下错误:http://dpaste.com/3KKCF84
编译器包含选项(无预包含):
"${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
在我看来,它需要一个存储时间的变量。我需要帮助分配该变量。
【问题讨论】:
标签: c makefile texas-instruments python-embedding