Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Building CUBRID CCI API on Mac OS X

In this tutorial we will go through the entire process of building CUBRID CCI API on Mac OS X. In this tutorial I will be using Snow Leopard.


Install Xcode

Apple's Xcode Developer Tools version 4.1 or later for Lion, 3.2 or later for Snow Leopard, or 3.1 or later for Leopard is required to build Macports (see below). Choose and download Xcode from Apple Developer Center. When installing ensure that the optional components for command line development are checked to be installed ("System Tools", "UNIX Development", or "Command Line Tools" in newer versions, or "Command Line Support" in older ones). The following is a screenshot of Xcode 3.2.6 on Snow Leopard.


Install Macports

Macports is a great, convenient package manager for Mac OS X. It simplifies many steps by automatically managing dependencies between packages. Some Linux-only packages have been ported to Mac and are available through Macports. To build CCI API we need some of those GNU packages available on Linux. So, we need Macports.

Macports is available in "pkg" installer. You can download it from Once downloaded, simply double click on the package to start the installation process.

Install Dev. Tools

Now install the tools required to build CUBRID source code.

sudo port install autoconf automake libtool
sudo port install coreutils


Checkout SVN source code

CUBRID Source Code is available at Checkout the latest version using the following command. In this tutorial we will download version 8.4.1.

svn co cubrid-8.4.1

Create Symlinks to GNU libs

We need to create symlinks to two GNU libs because Mac OS X version of these libs are not compatible with CUBRID source code as we use GNU version. So let's link them.

cd cubrid-8.4.1
ln -s /opt/local/bin/greadlink readlink
ln –s /opt/local/bin/glibtoolize libtoolize

these will create readlink and libtoolize symlinks in the root directory of CUBRID source code. Now we need to force the builder to use them instead of the Mac OS X version by appending the current directory path to $PATH.

user$ export PATH=/Users/user/Downloads/cubrid-8.4.1/:$PATH
user$ $PATH
-bash: /Users/user/Downloads/cubrid-8.4.1/:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin: No such file or directory

Configure files

Some files in CUBRID source code need to be executable while for some reason they are not. So we will fix this.

chmod +x cubrid-8.4.1/external/libregex38a/configure
chmod +x cubrid-8.4.1/external/libregex38a/configure.gnu
chmod +x cubrid-8.4.1/external/libregex38a/install-sh

For CUBRID 8.4.3 the following file also needs to be executable.

chmod +x cubrid-8.4.3/external/expat-2.0.1/configure
chmod +x cubrid-8.4.3/external/expat-2.0.1/configure.gnu

Set Java environmental variables

Since CUBRID supports Java Stored Procedures during this CCI API compilation process we need JDK to compile the source responsible for Java Stored Procedures. So let's set these variables.

In Snow Leopard

In Snow Leopard simply export the following path to JAVA_HOME variable. The Home directory already contains /include and /lib directories necessary for building CCI API. So we are good.

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home

In Mountain Lion

For some reason Apple has decided to put jni_md.h file into a separate directory under $JAVA_HOME/include/darwin/ instead of just $JAVA_HOME/include/. Since this file is required to build Java Stored Procedure feature in CUBRID, we need to hard copy (not symlink) this file to $JAVA_HOME/include/.

sudo cp $JAVA_HOME/include/darwin/jni_md.h $JAVA_HOME/include/

Apply Mac OS X specific changes

We need to edit CUBRID source code so that it correctly compiles under OS X.

Edit ./external/gc6.7/darwin_stop_word.c file.

  • 105 line:  Replace “esp” with “__esp”
  • 107 line:  Replace “eax” with “__eax”
  • 108 line:  Replace “ebx” with “__ebx”
  • 109 line:  Replace “ecx” with “__ecx”
  • 110 line:  Replace “edx” with “__edx”
  • 111 line:  Replace “edi” with “__edi”
  • 112 line:  Replace “esi” with “__esi”
  • 113 line:  Replace “ebp” with “__ebp”

Edit ./src/cci/cci_net_buf.h file.

Around the line 57 you will see the following code. Add the code marked in red:

#if (defined(SOLARIS) && !defined(SOLARIS_X86)) || defined(HPUX) || defined(AIX)
#elif defined(WINDOWS) || defined(LINUX) || defined(SOLARIS_X86) || defined(MAC_OS)
#error BYTE_ORDER_BIG_ENDIAN defined

Edit ./src/broker/cas_net_buf.h file.

Around the line 45 you will see the following code. Add the code marked in red:

#if (defined(SOLARIS) && !defined(SOLARIS_X86)) || defined(HPUX) || defined(AIX) || defined(PPC_LINUX)
#elif defined(WINDOWS) || defined(LINUX) || defined(OSF1) || defined(ALPHA_LINUX) || defined(UNIXWARE7) || defined(SOLARIS_X86) || defined(MAC_OS)
#error BYTE_ORDER_BIG_ENDIAN defined

Edit ./ file.

Around the line 54 you will see the following code. Add the code marked in red:

case $SYSTEM_TYPE in
SYS_LIBS="" ;;
*)       SYS_DEFS="-DMAC_OS"
SYS_LIBS="" ;;

If you are building CUBRID 8.4.3, you also need to edit ./src/cci/cci_common.h.

Line 71: #define gettid() syscall(__NR_gettid)

change to

#define gettid() getpid()

Run autogen

cd cubrid-8.4.1
mkdir build

Configure source code

Now configure the source code. Notice the --prefix path /usr/local/cubrid. This is where we will place CUBRID CCI API once we compile so that other dependent APIs like PHP, Python, etc. could link to our CCI API. At this moment we do not need to created that directory.

cd build
../configure --prefix=/usr/local/cubrid

If you are building CUBRID 8.4.3, before moving to the next final step, you need to make external libraries. In 8.4.1 this step was not required.

cd build/external


cd cubrid-8.4.1/build/cci
make -j

Congratulations! You can find the compiled CUBRID CCI API in cubrid-8.4.1/build/cci/.lib/. Below is a list of CCI API files you need to keep together if you want to further compile other APIs based on CCI.

  1. cubrid-8.4.1/build/cci/.libs/libcascci.8.dylib
  2. cubrid-8.4.1/build/cci/.libs/libcascci.a
  3. cubrid-8.4.1/src/broker/cas_error.h
  4. cubrid-8.4.1/src/cci/cas_cci.h

Copy them to /usr/loca/cubrid directory as shown below.

mkdir /usr/local/cubrid
mkdir /usr/local/cubrid/include
mkdir /usr/local/cubrid/lib
cd cubrid-8.4.1
sudo cp build/cci/.libs/libcascci.8.dylib /usr/local/cubrid/lib
sudo cp build/cci/.libs/libcascci.a /usr/local/cubrid/lib
sudo cp src/broker/cas_error.h /usr/local/cubrid/include
sudo cp src/cci/cas_cci.h /usr/local/cubrid/include
sudo ln -s /usr/local/cubrid/lib/libcascci.8.dylib /usr/local/cubrid/lib/


comments powered by Disqus
Page info
viewed 4889 times
translations en
posted 5 years ago by
updated 5 years ago by
View revisions
Share this article