0
\$\begingroup\$

I have a python file that I want to run on the board. Hence I want to embed the python interpreter (written in C) in the board. I managed to write separate C project that runs the Python file. It compiles and runs as I want to. Here's the makefile for same:-

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 is my entire directory of project "hello" (It is not the one from the examples).

I included "Classifier.h" in my "hello.c" and I am getting the following errors: http://dpaste.com/3KKCF84

Compiler include options (No 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}"

Linker file search paths:

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

and:

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

Am I wrong with some of my configurations? Or is this some problem with python interpreter? Any help is greatly appreciated

EDIT:- As @KevinDTimm suggested, the problem is that there is no pyconfig.h for my environment. This file is required by python to define important variables like source of system clock. I tried removing safety checks in existing pyconfig.h. The first error I am getting is in pytime.h as :

"_PyTime_t need signed 64-bit integer type"

Which was further because of the following code block:

#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

It appears to me that it needs a variable that stores time. I need help in assigning that variable.

\$\endgroup\$
  • \$\begingroup\$ Does your C compiler support the "unsigned long long" type? \$\endgroup\$ – brhans Jun 7 '17 at 16:50
  • 1
    \$\begingroup\$ I think you are going to end up playing "whack a mole" with various problems. Once you get the time problem fixed, something else won't work. Once that is fixed, then there'll be something else to fix, and so on ad infinitum. You will probably be better off porting your own program from python to C. \$\endgroup\$ – JRE Jun 7 '17 at 17:50
  • \$\begingroup\$ @JRE It's a machine learning program using GradientBoosting algorithm. I tried going that way as well but there are no well documented libraries to do that. \$\endgroup\$ – Meet Taraviya Jun 8 '17 at 4:43
  • \$\begingroup\$ @brhans Yes it does support it. It also supports all the uintXX_t types. Why do you ask? \$\endgroup\$ – Meet Taraviya Jun 8 '17 at 4:46
  • 1
    \$\begingroup\$ TBH I think you need to go back to the drawing board. Identify your requirements & constraints before picking a hardware platform. If you need to have python interpreter, then choose hardware which has one already supported. If you can't choose different hardware, then budget for extra time to write your code in C ... \$\endgroup\$ – brhans Jun 8 '17 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.