Hi all!
I installed python 3.9.1 on my Raspberry Pi following the instructions here and set it as the default python interpreter. I got my compiling and linking parameters for embedded Python following the instructions here
I tried a simple test with the following code (test.c) :
and
and got
I installed python 3.9.1 on my Raspberry Pi following the instructions here and set it as the default python interpreter. I got my compiling and linking parameters for embedded Python following the instructions here
I tried a simple test with the following code (test.c) :
int main(int argc, char *argv[]) { wchar_t *program = Py_DecodeLocale(argv[0], NULL); if (program == NULL) { fprintf(stderr, "Fatal error: cannot decode argv[0]\n"); exit(1); } Py_SetProgramName(program); /* optional but recommended */ Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print('Today is', ctime(time()))\n"); Py_Finalize(); PyMem_RawFree(program); return 0; }and then
gcc -I/usr/local/opt/python-3.9.1/include/python3.9 -I/usr/local/opt/python-3.9.1/include/python3.9 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -c test.c -o test.o
and
gcc -L/usr/local/opt/python-3.9.1/lib/python3.9/config-3.9-arm-linux-gnueabihf -L/usr/local/opt/python-3.9.1/lib -lcrypt -lpthread -ldl -lutil -lm -o test.o
and got
Error:/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crt1.o: In function '_start':
/build/glibc-P1SmLh/glibc-2.19/csu/../ports/sysdeps/arm/start.S:119: undefined reference to 'main'
collect2: error: ld returned 1 exit status
Trying to compile the example over here throws the same error. What could the problem be?