14/01/17

Compiling Clingo with Anaconda (to enable the Python bridge to Clingo)

Compiling clingo

I have downloaded the sources of clingo from https://github.com/potassco/clingo/releases.

apt-get install gcc g++ scons bison re2c pkg-config python-dev

I discovered that without python-dev pkg-config was not able to correctly identify python. If you already launched scons before, and it does not find python after installing python-dev, try to delete the directory and unzip again the source files, the scons cache seemed to give me some problems.

I added the flags '-pthread' in CXXFLAGS and LINKFLAGS in build/release.py, as solveIter() asked for thread support. 

According to the INSTALL instructions, I had to install the tbb library (I also installed cppunit, which was in the initial check of scons).

apt-get install libtbb2 libtbb-dev libcppunit


Python module with Anaconda 

Even with this discovery, I was not able to compile clingo with python support. Despite all my efforts, although python-config and pkg-config were available on the command line, they were not recognized by scons, when following the INSTALL instructions. I decided to work out a solution with anaconda.

I finally managed to run it modifying by hand the build/release.py [replace my anaconda2 path with your own path]

CXX = 'c++'
CC = 'cc'
CXXFLAGS = ['-std=c++11', '-O3', '-Wall', '-fvisibility=hidden']
CFLAGS = ['-O3', '-Wall']
CPPPATH = ['/home/giovanni/anaconda2/include/python2.7']
CPPDEFINES = {'NDEBUG': 1}
LIBS = ['python2.7']
LIBPATH = ['/home/giovanni/anaconda2/lib']
LINKFLAGS = ['-std=c++11', '-O3']
CLINKFLAGS = []
RPATH = []
AR = 'ar'
ARFLAGS = ['rc']
RANLIB = 'ranlib'
BISON = 'bison'
RE2C = 're2c'
PYTHON_CONFIG = 'python-config'
PKG_CONFIG = 'pkg-config'
WITH_PYTHON = 'auto'
WITH_LUA = 'auto'
WITH_THREADS = 'posix'
TESTS = ['libreify', 'libgringo', 'libclingo', 'liblp', 'clingo']


In this way it worked, as I checked with:
 
> scons configure --build-dir=release 
output:

scons: Reading SConscript files ...
Checking for bison 2.5... (cached) yes
Checking for re2c... (cached) yes
Checking whether the C++ compiler works... (cached) yes
Checking whether the (shared) C++ compiler works... (cached) yes
Checking for C++ thread_local keyword... yes
Auto-detecting python (python-config)... yes
Auto-detecting lua (pkg-config)... no
Checking for C++ function snprintf()... yes
Checking for C++ function vsnprintf()... yes
Checking for C++ function std::to_string()... yes
scons: done reading SConscript files.
scons: Building targets ...
scons: Nothing to be done for `configure'.
scons: done building targets.

Nessun commento:

Posta un commento