pythonarmcross-compiling

Cross compiling py-spidev for arm


I'm trying to cross-compile py-spidev module for an ARM9 (embedded system).

In an Ubuntu 64-bit VM, I did this(in my home directory):

git clone https://github.com/doceme/py-spidev
cd py-spidev
export PATH=$PATH:"Path_to_my_cross_compiler"
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
python setup.py install --prefix=~/

But spidev_module.c is compiled with x86_64-linux-gnu-gcc and not my cross-compiler (arm-poky-linux-gnueabi-gcc).

How can I force python setup.py install to use my cross compiler?


Solution

  • I found the solution, so I post it for those who have the same problem.

    This is what I did :

    git clone https://github.com/doceme/py-spidev
    cd py-spidev
    export ARCH=arm
    PLAT=arm-poky-linux-gnueabi-
    export CROSS_COMPILE=arm-poky-linux-gnueabi-
    export PATH=$PATH:"Path_to_my_cross_compiler"
    export CC="${PLAT}gcc -pthread"
    export LDSHARED="${CC} -shared"
    export CROSSBASE="Path of destination"
    export CFLAGS="-I "path to python cross compiled include" -I${CROSSBASE}/usr/include"
    export LDFLAGS="-L "path to python cross compiled libs" -L${CROSSBASE}/lib -L${CROSSBASE}/usr/lib"
    python setup.py install --prefix=CROSSBASE
    

    Enjoy :)