Building OpenCog on Mac OS X with MacPorts

From OpenCog
Jump to: navigation, search

The tested way of setting up workspace on mac is by using docker, see here.

For general instructions see Building OpenCog.

These are instructions for a progressive build of OpenCog on Mac OS X 10.11 El Capitan (the process is the same for 10.10 Yosemite and older versions, however download locations for XCode and its add-ons are different; please see the talk page).

Please report build issues on github.

Prepare your system

Install the latest updates from Apple via Apple Menu > Software Update

Install Apple Xcode

Install XCode from Mac App Store (XCode 4.6 at the time of this writing)

Install XCode Command Line Tools from https://developer.apple.com/downloads/index.action (February 2013 at the time of this writing)

Accept XCode license agreement

Open a command line, e.g. from Macintosh HD > Applications > Utilities > Terminal.

The boxes below surrounded with dotted lines are commands to be pasted onto the command line.

xcodebuild -version

With Homebrew

Install Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If already installed, update it before proceeding further.

brew update

Install build tools

brew install gcc
brew install cmake
brew install CxxTest

Note: The commands above will also download, build and install necessary dependencies, such as a C compiler and other libraries and tools. If your system hasn't been used before to build software, it may take many hours.

CxxTest is optional.

Install build dependencies

brew install boost
brew install gsl
brew install guile
pip install cython

Update bash profile

echo 'alias g++="g++-5 --std=c++1y -fext-numeric-literals"' >> ~/.bash_profile
echo 'alias gcc="/usr/local/Cellar/gcc/5.1.0/bin/gcc-5"' >> ~/.bash_profile
echo 'export CC="/usr/local/Cellar/gcc/5.1.0/bin/gcc-5"' >> ~/.bash_profile
echo 'export CXX="g++-5 --std=c++1y -fext-numeric-literals"' >> ~/.bash_profile
source ~/.bash_profile

Note: There may be issues with different versions of gcc/g++ installed on your system. Make sure that you have correct version of gcc and g++ installed in the directory, mentioned in command above otherwise errors may pop up while building OpenCog repositories as they only support GNU gcc and g++ at this time.

Fetch OpenCog source repositories

brew install git
git clone git://github.com/opencog/cogutil
git clone git://github.com/opencog/atomspace
git clone git://github.com/opencog/moses
git clone git://github.com/opencog/opencog

Compile and install CogUtil

cd cogutil
mkdir build
cd build
cmake ..
make && make test && sudo make install
cd ../..

Compile and install AtomSpace

cd atomspace
mkdir build
cd build
cmake ..
make && make test && sudo make install
cd ../..

Compile and install MOSES

cd moses
mkdir build
cd build
cmake ..
make && sudo make install
cd ../..

Compile and install OpenCog

cd opencog
mkdir build
cd build
cmake ..
make && sudo make install
cd ../..

Test CogServer

To sidestep @rpath issues, modules load with LD_LIBRARY_PATH set, e.g.

export OPENCOG_BIN=$HOME/opencog/bin
export LD_LIBRARY_PATH=$OPENCOG_BIN/opencog/server:$OPENCOG_BIN/opencog/shell
opencog/server/cogserver

Telnet to local port

telnet localhost 17001

Interact with cogserver

>opencog help

With Macports

This method hasn't been tested since OpenCog was split into 4 repos. Feel free to update this section, if you get it working with Macports.

Install Macports

Follow the instructions mentioned here.

Install build tools

sudo port install gcc47
sudo port install cmake

Note: The commands above will also download, build and install necessary dependencies, such as a C compiler and other libraries and tools. If your system hasn't been used before to build software, it may take many hours.

Install build dependencies

sudo port install boost
sudo port install gsl
sudo port install guile

Fetch OpenCog source repositories

sudo port install git-core
git clone git://github.com/opencog/cogutil
git clone git://github.com/opencog/atomspace
git clone git://github.com/opencog/moses
git clone git://github.com/opencog/opencog

Compile and install CogUtil

cd cogutil
mkdir build
cd build
cmake ..
make && sudo make install
cd ../..

Compile and install AtomSpace

cd atomspace
mkdir build
cd build
cmake ..
make && sudo make install
cd ../..

Compile and install MOSES

cd moses
mkdir build
cd build
CC="gcc-mp-4.7" CXX="g++-mp-4.7" cmake ..
make && sudo make install
cd ../..

Compile and install OpenCog

cd opencog
mkdir build
cd build
cmake ..
make && sudo make install
cd ../..

Test CogServer

To sidestep @rpath issues, modules load with LD_LIBRARY_PATH set, e.g.

export OPENCOG_BIN=$HOME/opencog/bin
export LD_LIBRARY_PATH=$OPENCOG_BIN/opencog/server:$OPENCOG_BIN/opencog/shell
opencog/server/cogserver

Telnet to local port

telnet localhost 17001

Interact with cogserver

>opencog help

Update Ports

sudo port selfupdate
sudo port upgrade outdated