Oracle Solaris and unixODBC

In a project, I’m asked to create a database link between Oracle to MySQL. I thought that I can use Oracle’s Heterogeneous Services. Oracle Database is running on Sparc Server (Solaris 10), so I downloaded the free ODBC packages from unixODBC project. They already provide a binary package for Solaris but it says it will remove any non pkgmgr content in “/usr/local/bin” directory. So I decided to download the source codes and build it manually. Although it sounds like a scientific operation, you just need to run 3 commands to build and install the package in normal conditions but oh unfortunately it took a lot of time to fix “library” dependencies problem and adding MySQL support to unixODBC.

Here are the commands to build unixODBC:

So these commands will configure the make file, then compile the sources and copy them to “/usr/local/unixODBC” with the required (or sample) files.

Actually it worked as expected. Then I downloaded MySQL ODBC Connector (binary distribution for Solaris Sparc), unzip its content and copied the library file into the unixODBC directory and tried to configure ODBC:

As you may notice, I have even created required symbolic links (libodbcinst.so.1 and libodbc.so.1 for MySQL Connector). At the end, I get this error:

[01000][unixODBC][Driver Manager]Can’t open lib ‘/usr/local/unixODBC/lib/libmyodbc5.so’ : file not found

The library was surely there and accessible by root, so why does it say file not found. After playing with “ldd” and “file” commands, I noticed that “libmyodbc5.so” is 64 bit but somehow my unixODBC is compiled in 32 bit:

After lots of googleing, I found the solution. I removed the unixODBC, set “CFLAGS” to “-m64” and then recompile the unixODBC:

Everything went OK, I configured ODBC (copied MySQL connector etc), but same error occurred again. I don’t know why but although it’s compiled in 64 bit, it was trying to use /usr/local/lib/libgcc_s.so.1 which is 32bit! I found the correct libgcc_s.so.1 in “/usr/sfw/lib/sparcv9/” so I created this link in /usr/local/unixODBC/lib:

And it worked! Moral of the story, you may need to set CFLAGS=”-m64″ for compiling software in 64bit, “file” command will show you if your library is 32 or 64bit (very important to solve architectural problems) and “ldd” shows libraries dependencies of a file (another life-saver).

Please share
  •  
  •  
  •  
  •  
  •  
  •  

AWS Big Data Specialist. Oracle Certified Professional (OCP) for EBS R12, Oracle 10g and 11g. Co-author of "Expert Oracle Enterprise Manager 12c" book published by Apress. Awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for the continuous contributions to the Oracle users community. Founding member, and vice president of Turkish Oracle User Group (TROUG). Presented at various international conferences including Oracle Open World.

2 Comments

  1. Eric

    Yes, I was stumped until I found this post!  Thank you so much.  You saved the day!

Leave Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.