14
$\begingroup$

Due to the high availability of python code for the rpi, I'm trying to call python functions from Mathematica. I know that pythonika works well on OS X, but I can't compile it on the Raspberry pi.

This is the repository for pythonika:

https://github.com/erocarrera/pythonika

I suspect that I need to change the Makefile.linux to match Raspberry pi settings. But so far I havent been able to succeed.

$\endgroup$
15
$\begingroup$

I was able to do it. I'll post what I did in case somebody else needs it. So far it works really nice. Just follow the instructions from the repository, and modify the Makefile.linux with the following code, saved as Makefile.linux:

# Set the paths according to your MathLink Developer Kit location.
# (The paths should not contain whitespaces)

MATHEMATICA_INSTALL_DIR = /opt/Wolfram/WolframEngine/10.3
MLINKDIR = ${MATHEMATICA_INSTALL_DIR}/SystemFiles/Links/MathLink/DeveloperKit

SYS = Linux-ARM
CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions

INCDIR = ${CADDSDIR}
LIBDIR = ${CADDSDIR}

MPREP = "${CADDSDIR}/mprep"
MCC = "${CADDSDIR}/mcc"

# Modify the following for Python versions other than 2.6
PYTHON_VERSION_MAJOR = 2
PYTHON_VERSION_MINOR = 7


# Path to the Python includes (modify according to Python version)
#
PYTHONINC = /usr/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/


PYTHONIKA = Pythonika
INCLUDES = -I${INCDIR} -I${PYTHONINC}

# libstdc++ and librt are, apparently, needed for correct compilation under Linux
# with libMLi3 statically linked
#
LIBS = -L${LIBDIR} ${LIBDIR}/libML32i4.a -lstdc++ -lrt -lm -pthread -luuid -ldl -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}


all : Pythonika

Pythonika: ${PYTHONIKA}.o ${PYTHONIKA}tm.o
    ${CC} ${INCLUDES} ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${LIBS} -o ${PYTHONIKA}

${PYTHONIKA}tm.o: ${PYTHONIKA}.tm
    ${MPREP} ${PYTHONIKA}.tm -o ${PYTHONIKA}tm.c
	${CC} -c ${PYTHONIKA}tm.c ${INCLUDES}

${PYTHONIKA}.o: ${PYTHONIKA}.c
    ${CC} -c ${PYTHONIKA}.c ${INCLUDES}

clean :
    rm -f ${PYTHONIKA}tm.* ${PYTHONIKA}.o ${PYTHONIKA}

Now open the Pythonika.nb notebook and run the code.

I'll update this if I find any issues.

$\endgroup$
  • 3
    $\begingroup$ I edited your post directly include the code rather than your google drive file, which is less permanent. $\endgroup$ – anderstood Oct 3 '16 at 0:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.