如何在 Ubuntu 上安装 Pythonika?

如何在 Ubuntu 上安装 Pythonika?

我尝试安装派提卡在我的 Ubuntu 14.04 (64) 上,使用 python 2.7.6。我遵循了 Salem 的回答,但有一些错误。

Makefile.linux

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

MATHEMATICA_INSTALL_DIR = /usr/local/Wolfram/Mathematica/10.0
MLINKDIR = ${MATHEMATICA_INSTALL_DIR}/SystemFiles/Links/MathLink/DeveloperKit

SYS = Linux-x86-64
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
#
##     Ununtu 14.04 
LIBS = -L${LIBDIR} ${LIBDIR}/libML64i3.a -lstdc++ -lpthread -lm -lrt -    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}

错误是

cc -I/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -I/usr/include/python2.7/ Pythonika.o Pythonikatm.o -L/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions        /usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a -lstdc++ -lpthread -lm -lrt -lpython2.7 -o Pythonika
Pythonikatm.o: In function `MLAnswer':
Pythonikatm.c:(.text+0xba8): undefined reference to `MLWaitForLinkActivity'
/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a(mluuid.cpp.o): In function `MathLink::MLUUID::stringRepresentation() const':
mluuid.cpp:(.text+0x7e): undefined reference to `uuid_unparse_upper'
/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a(mluuid.cpp.o): In function `MathLink::MLUUID::operator=(std::basic_string<char, std::char_traits<char>, MathLink::MLStdAllocator<char> > const&)':
mluuid.cpp:(.text+0xd4): undefined reference to `uuid_parse'
/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a(mluuid.cpp.o): In function `MathLink::MLUUID::MLUUID(std::basic_string<char, std::char_traits<char>, MathLink::MLStdAllocator<char> > const&)':
mluuid.cpp:(.text+0x17b): undefined reference to `uuid_parse'
/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a(mluuid.cpp.o): In function `MathLink::MLUUID::MLUUID()':
mluuid.cpp:(.text+0x227): undefined reference to `uuid_generate'
collect2: error: ld returned 1 exit status
make: *** [Pythonika] Error 1

答案1

没有可用的编译版本与您的 OS/arch 匹配,因此您需要自行编译。大致而言,您需要遵循以下步骤:

  • 安装建筑工具

    $ sudo apt-get install build-essential subversion python-dev
    
  • 获取源代码:

    $ svn checkout http://pythonika.googlecode.com/svn/trunk/ pythonika-src
    $ cd pythonika-src
    
  • 编辑文件Makefile.linux并检查路径MATHEMATICA_INSTALL_DIR是否正确。此外,您还需要更改PYTHON_VERSION_MINOR为“7”(如果您使用的是默认安装的 Python 版本)。

  • 编译

    $ make -f Makefile.linux
    

如果一切顺利,您应该Pythonika在该文件夹中有一个名为的文件。如果出现任何错误,请使用您遇到的错误更新您的问题。

答案2

您必须安装uuid-dev软件包。您可以在终端中执行此命令(要启动终端,请执行++ CRTL):ALTT

sudo apt-get install uuid-dev

并在Makefile.linux文件中说明您需要该库libuuid.so。为此,请编辑文件并添加-luuid以下行:

LIBS = -L${LIBDIR} ${LIBDIR}/libML64i3.a -lstdc++ -lpthread -lm -lrt -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}

因此你应该有类似这样的内容:

LIBS = -L${LIBDIR} ${LIBDIR}/libML64i3.a -lstdc++ -luuid -lpthread -lm -lrt -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}

就这样。

相关内容