A three course, cross-platform feast. Yum!

This post is for you, if you’re thinking Sybase, MacOS X, Linux, Solaris and REALbasic.

As a Solaris, Macintosh and Windows site we have consciously avoided adding Linux into the mix. For various reasons we have now added a linux server into our server racks (think 1000 cpu bioinformatics server). Here is how I enabled my 64 bit iMac, using 32 bit REALbasic, to remote debug onto a 64 bit Centos Linux box that subsequently launched a 32 bit RB web application that connected to a remote 32 bit Sybase server running on 64 bit Solaris. Mac, to Linux, to Solaris. Three 64 bit operating systems running three separate 32 bit servers. Talk about cross platform.

Some other terms to help you grok the usefulness of this article before we begin: Sybase Adaptive Server, Open Client, remote debugging, odbc and 7 days of hair-pulling.

Oh and yum!

Let’s follow the flow of bits from Mac to Sybase via Figure 1:

Image

The mouse is our Web App. All other icons belong to the icon holders.

First up, we tried using ODBC as the connection mechanism between our mouse RB web app and Sybase, but I could not get the RB ODBC plugin (2012r1-post release nor the RB2011r2 versions) to connect. No error was returned, but the connection failed. Using /usr/bin/isql, which is the unixODBC equivalent of the Sybase isql command worked from the command line, but we could not get the RB ODBC plugin to connect.

Anyway, lets step though the steps we took to make a remotely debugged web app.

First install Centos. No idea how to do this as the IT guys gave us an IP of a VMware virtualised headless 64 bit Centos box.

Next install the Sybase Open Client libraries. Maybe you can just download the libraries but I just downloaded the Sybase Adaptive Server Enterprise Express Edition. Installation is a tedious command line. We took the default options so it ended up in /opt/sybase. Then we added our Sybase servers to the interfaces file and a quick test with the sybase isql tool showed that we could connect to the newly installed local ASE as well as the remote server on Sun Solaris. When I say quick, I mean we are now at maybe day 2 or 3 of hair pulling after getting the IP and login details.

Day 4 and 5 were wasted on installing and failing with unixODBC and easysoft. 32 bit ODBC on 64 linux. What a nightmare…

Day 6 meant abandoning the ODBC turd and attack the server via an Open Client method.

RB apps are 32 bits, but our Centos was 64 bits. We also use PHP and installed it via the fantastic yum installer. yum will save you a lot of trouble. Because PHP 5.3.1 will look for Sybase ASE open-client libraries from Sybase ASE v12.x you need to trick PHP and create symbolic links in $SYBASE/$SYBASE_OCS/lib for each of the following libraries

/opt/sybase/OCS-15_0/lib/libintl_r.so ->; libsybintl_r.so
/opt/sybase/OCS-15_0/lib/libcomn_r.so ->; libsybcomn_r.so
/opt/sybase/OCS-15_0/lib/libcomn.so ->; libsybcomn.so
/opt/sybase/OCS-15_0/lib/libcs_r.so ->; libsybcs_r.so
/opt/sybase/OCS-15_0/lib/libcs.so ->; libsybcs.so
/opt/sybase/OCS-15_0/lib/libct_r.so ->; libsybct_r.so
/opt/sybase/OCS-15_0/lib/libct.so ->; libsybct.so
/opt/sybase/OCS-15_0/lib/libintl.so ->; libsybintl.so

This link was helpful for this step: http://sybase-addict.com/2010/01/16/sybase-ase-v15-apache-and-php-compilation/

The only slightly disastrously problem is that REALbasic doesn’t actually talk to these Open Client (OCS) libraries, but thankfully the MonkeyBread software (MBS) database plugin does.
The code to actually do this took some guessing and debugging before it fell into place.

If you are reading this and you are in the same predicament, I am now about to show you something that will make your day and allow you to bypass a lot of pain. Here it is.

dim ASEdb as SQLDatabaseMBS

ASEdb = New SQLDatabaseMBS

ASEdb.Password=me.Password //from an editfield
ASEdb.UserName=me.UserName //from an editfield
ASEdb.DatabaseName = “Sybase:SYBASE@grants” //from .ini file or from an editfield

dim libct as FolderItem
libct = new FolderItem(“/opt/sybase/OCS-15_0/lib/libct.so”, FolderItem.PathTypeShell)
ASEdb.SetFileOption(ASEdb.kOptionLibrarySybaseCT, libct)

dim libintl as FolderItem
libintl = new FolderItem(“/opt/sybase/OCS-15_0/lib/libintl.so”, FolderItem.PathTypeShell)
ASEdb.SetFileOption(ASEdb.kOptionLibrarySybaseIntl, libintl)

dim libcomn as FolderItem
libcomn = new FolderItem(“/opt/sybase/OCS-15_0/lib/libcomn.so”, FolderItem.PathTypeShell)
ASEdb.SetFileOption(ASEdb.kOptionLibrarySybaseComn, libcomn)

dim libsybtcl as FolderItem
libsybtcl = new FolderItem(“/opt/sybase/OCS-15_0/lib/libsybtcl.so”, FolderItem.PathTypeShell)
ASEdb.SetFileOption(ASEdb.kOptionLibrarySybaseTCL, libsybtcl)

dim libcs as FolderItem
libcs = new FolderItem(“/opt/sybase/OCS-15_0/lib/libcs.so”, FolderItem.PathTypeShell)
ASEdb.SetFileOption(ASEdb.kOptionLibrarySybaseCS, libcs)

ASEdb.AutoCommit = 0 ‘ off

if ASEdb.Connect = false then
msgbox ASEdb.ErrorMessage
Return false
end if

//woohoo!!
…continue with RB code

This code took another 2 days to figure out.

Looking back at any trek, it all seems so obvous and easy and you cannot understand why it took you so long to not figure out that path in the first place…. This was a journey like that. Obvious once you know how.

Anyway, lets talk about this code.

SQLDatabaseMBS returns standard REALbasic recordsets.
I used SQLDatabaseMBS so that all my old code would continue to work.

Next you add the password and username. Do not add .host/.port. The entire configuration is done in the next step: ASEdb.DatabaseName = “Sybase:SYBASE@grants”

So what is happening here. Firstly, “Sybase:” is a message to the MBS plugin that it should be prepared to talk to the Sybase Open Client libraries.
“:SYBASE@” is telling the Sybase Open Client libraries that they will be using the server “SYBASE” as defined in the INTERFACEs file on Centos. For us “SYBASE” is not on the Centos box but on a third machine, where Sybase is running on Solaris.
“@grants” is telling the Sybase Open Client libraries that they will be using the grants database on this Solaris Sybase server.

Next in the REALbasic code is configuring the MBS plugin and the location of the various OCS libs eg kOptionLibrarySybaseCT, kOptionLibrarySybaseIntl etc

Once this is done you can use ASEdb.Connect to connect.

But we are not quite done. I want debugging in my web apps and that means “Remote Debugging”. Remember this is a headless Centos box.

So, you install the linux “Remote Debugger Stub” and run it from the command line. And here you hit another hurdle as the stub requires a GUI. Just another roadblock in the journey of life until you remember that X11 thing that you used to use a million years ago. Apparently X11 has been kept alive and you can install the linux components via yum and the Mac components via the XQuartz project.

Again I will save you some hair.

From your Mac, ssh to the linux box, but add the -X command

eg ssh -l username -X your.centos.server -C

Now on Centos you start the stub ./Remote\ Debugger\ Stub.

I get a few shell errors “(Remote Debugger Stub:16522): Gtk-WARNING **: Unable to locate theme engine in module_path: “clearlooks” but after a few seconds the XQuartz application launches on my Mac and I see the stub

Image

Now in REALbasic you configure the “Run Remotely” dialog and with some luck you will see your sweet, sweet file being uploaded to the linux box after the build.

02:59:48 PM: Stub->;IDE FILECREATION, File ID: 0, Status: 0
02:59:49 PM: Stub<;-IDE FILEINFO, File ID: 0, Size: 1.562522e+7, Compressed: False, Stub Delete: False
02:59:49 PM: Stub<;-IDE FILEPART, File ID: 0

etc

etc

So that's how you enable your Mac to remote debug Sybase client web apps onto linux. Not easy eh!

PS.

Whenever I had an error message about a missing shared library I used yum to find a package that had it. The failed ODBC path meant I installed a lot of libs that may not have been necessary or were necessary for RB. What am I trying to say? If you followed the steps above and still have libs missing then try yum search missing_lib to find packages with the dependant libs. For example I think I had to install glibc at some point in the 6 days of hair-pulling that lead to this article.

Advertisements

Tags: , ,

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s


%d bloggers like this: