SQLite, JDBC & Solaris (SPARC)

SQLite is one of simple and powerful Database engine. Recently I was doing some testing and performance check, using a Java Code and Xerial SQLite-JDBC library. As a part of this, I wanted to run this test on Solaris 11 (SPARCv9) environment.  Thats when I noticed two things:

1) Xerial SQLite JDBC Library not having the Native Library for Solaris SPARC  Architecture. JDBC Native Library is used to bridge the Java JDBC call to SQLite C Call. It is simple JNI Wrapper library.

2) My Solaris Base machine as well as the spare VM does not have the GNU Developer Tools.

I am not regularly playing with Solaris Package System and  not sure about the impact of installing the new set of libraries and tools in the base machine. So decided use the spare Oracle VM and not to touch the base machine.

Installing GNU Developer Tools in Solaris 11 SPARC:

Starts with GCC and supporting library installation. But this

# pkg install gcc or gcc-4X

Failed with message “This version is excluded by installed incorporation blah blah”. All my other tricks to install gcc also failed. But I was able to install vim  using:

# pkg install vim

This event pushed me to read about the Package Incorporation in Oracle documents:
“Every package that is part of the Oracle Solaris 11 OS has a dependency on an incorporation package. Incorporation packages constrain the versions of the their incorporated packages to help keep the system in a supportable state across updates. Some incorporated packages might be safe to downgrade or upgrade at a version different from the version specified by the incorporation”.

You have an option to relax some (version) constraints to allow the installation any package. GNU Developer tools might have some inter-dependency, I don’t want to go in this direction and decide to search list of incorporated packages. Below command listed the packages:

# pkg contents -m ips-incorporation

And following line in the output, give me a clue.

depend fmri=group/feature/developer-gnu@0.XXX type=incorporate

developer-gnu is a group package and it can install all the tools with correct dependency, in one go.

# pkg install developer-gnu

All GNU tools are installed with-out any issue. Ah, next..

Compile SQLite-JDBC on SPARC:

Developers didn’t compile it for the SPARC platform. But they put a place holder in the Makefile. This reduced my job to few fine tuning only. Let see thous steps:

1. Install the JDK (I used JDK 1.8) and Set the JAVA_HOME

2. Get the Xerial SQLite-JDBC library source from GitHub (I used 3.15)

3. During the compilation process, original SQLite code will be download. So target machine need to have the Internet access or you need to change the Makefile to use locally downloaded files.

3. Changes in Makefile.common:

A) Add -std=gnu99 — To support C99 Standard

SunOS-sparcv9_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC  -m64 -std=gnu99 -fvisibility=hidden

B) For 32 bit binary, then add the following:

SunOS-sparc_CC := $(CROSS_PREFIX)gcc
SunOS-sparc_STRIP := $(CROSS_PREFIX)strip
SunOS-sparc_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC  -m32 -std=gnu99 -fvisibility=hidden
SunOS-sparc_LINKFLAGS := -shared -static-libgcc
SunOS-sparc_LIBNAME := libsqlitejdbc.so

C) Added new target to known_targets:

known_targets := .. SunOS-sparc

4. Changes in Makefile:

A) For 32 bit binary, then add the following:

          $(MAKE) native OS_NAME=SunOS OS_ARCH=sparc

5. Build the native part

$ gmake sparcv9

$ gmake sparc

You can find the native library (libsqlitejdbc.so) in the folders:
32 bit: target/sqlite-3.15.1-SunOS-sparc
64 bit: target/sqlite-3.15.1-SunOS-sparcv9

6. Rebuild the JAR:

I am not building it for multiple platforms. It is also not possible. Because the some part of the build step depends on docker images, which is not supported in my VM. So I left with only one option of manually adding this native library into the sqlite-jdbc-3.15.X.jar JAR.

A) Download the latest JAR file.
B) Extract it (JAR is simply a ZIP File)
C) Create “SunOS” folder inside the /org/sqlite/native/
D) Create “sparc” and “sparcv9” folders inside the SunOS
E) Copy the libsqlitejdbc.so into corresponding folders (32 and 64)
F) Recreate the JAR

Now JAR ready for the Solaris SPARC platform. HTH 🙂

4 thoughts on “SQLite, JDBC & Solaris (SPARC)

  1. Hi Bharathi,

    Could you please let us know where we can find the source code to generate libsqlitejdbc.so for Solaris.

    Thanks & Regards,

  2. Hi Bharathi,
    I can’t compile it without a sparc architecture machine. Could you send me the jar package?

  3. Thank you
    I succeeded this way
    Solaris 11.4 / sqllite-jdbc-3.32.3
    Thank you very much

    1. pkg install gcc
    2. pkg install developer-gnu
    3. change file Makefile.common
    SunOS-sparcv9_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC -m64 -std=gnu99 -fvisibility=hidden
    4. gmake sparcv9
    5. change jar file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: