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.

Requirements

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 http://www.macports.org/install.php/. Once downloaded, simply double click on the package to start the installation process.

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.

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 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
./autogen.sh

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 makeexternal libraries. In 8.4.1 this step was not required.

cd build/external
make

Compile CUBRID CCI API

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.