I want to call Mathematica from C code and C code from Python. I have the individual parts working, but I can't put everything together.
When I compile the C code that calls Mathematica, then I use the following command in makefile
$(CC) -O mlcall.c -I$(INCDIR) -L$(LIBDIR) -l${MLLIB} ${EXTRALIBS} -o $@
Where
MLINKDIR = /opt/Mathematica-9.0/SystemFiles/Links/MathLink/DeveloperKit
SYS=Linux-x86-64
CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions
INCDIR = ${CADDSDIR}
LIBDIR = ${CADDSDIR}
MLLIB = ML64i3
My question is how can I use distutils with those same options (currently I'm getting undefined symbol: MLActivate error, when calling from Python and I think the problem is because I'm not using these options)?
I saw the answer https://stackoverflow.com/a/16078447/1335014 and tried to use CFLAGS (by running the following script):
MLINKDIR=/opt/Mathematica-9.0/SystemFiles/Links/MathLink/DeveloperKit
SYS="Linux-x86-64"
CADDSDIR=${MLINKDIR}/${SYS}/CompilerAdditions
INCDIR=${CADDSDIR}
LIBDIR=${CADDSDIR}
MLLIB=ML64i3
EXTRALIBS="-lm -lpthread -lrt -lstdc++"
export CFLAGS="-I$INCDIR -L$LIBDIR -l${MLLIB} ${EXTRALIBS}"
So I get the following output for echo $CFLAGS
-I/opt/Mathematica-9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -L/opt/Mathematica-9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -lML64i3 -lm -lpthread -lrt -lstdc++
Which seems correct, but didn't have any effect. Maybe because I'm adding more than one option.