1

so I managed to use Python in helloworld C program.

#include <Python.h>
int main(){
printf("This is C\n");
Py_Initialize();
PyRunSimpleString("print('this is python')");
Py_Finalize();
return 1;}

I had to sudo apt-get install python-dev and python3-dev as well. Just in case.

To compile and run this I used following commands:

gcc -c $(python2.7-config --cflags) cprog.c
gcc cprog.o $(/usr/bin/python2.7-config --ldflags)
./a.out

Everything works so far. Now I have user-mode-linux from git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

I need to be able to use Python from arch/um/drivers/ubd_kern.c. But when I as much as even insert the #include <Python.h> and try to compile everything with make V=1 ARCH=um it fails.

It appears that usermode linux has a -nostdinc flag. So I tried to link the Python.h file and added CFLAGS_ubd_kern.o := -DTEST77 -I/home/alli/pyhack $(shell python2.7-config --cflags) to arch/um/drivers/Makefile but then the compilation results in multiple conflicts.

How can I use Python from user-mode-linux's drivers? Thanks in advance.

alli
  • 11
  • 1

0 Answers0