SqueakDBX - Compiling and installing OpenDBX
Last updated at 1:00 am UTC on 8 July 2009
Before you can start using SqueakDBX, you need OpenDBX. You can install openDBX from binaries or you can compile it by yourself. At this point, you should be asking yourself which version to use. Because of this, we have in class OpenDBX a class method called currentOpenDBXVersion that tells you which version you must use. In addition, you can see SqueakDBX - ChangeLog information. In both cases, you must have installed your database client library first.
To install openDBX from binaries, you can find these files in http://www.linuxnetworks.de/doc/index.php/OpenDBX/Setup/Unix-like. The linker searches for the library in its configured paths (/etc/ld.so.conf) or in the directory in LD_LIBRARY_PATH. Windows DLLs either have to be in the program directory (i. e. the directory where squeak.exe resides), in a directory in %PATH% or in c:/windows/system32. You can download dll from here http://www.linuxnetworks.de/doc/index.php/OpenDBX/Setup/Windows. You must also install the libopendbx-dev package.
Example of a .deb instalation:
$ sudo dpkg -i libopendbx_1.4.0-1_i386.deb libopendbx-mysql_1.4.0-1_i386.deb
and then:
$ sudo dpkg -i libopendbx1-dev_1.4.0-1_i386.deb
You can see here how to compile and install OpenDBX:http://www.linuxnetworks.de/doc/index.php/OpenDBX/Setup/Manual_builds.
What it's important here is that when you compile OpenDBX, you have to specify the database engines you want. When you do the './configure', OpenDBX will check if you have already installed the client library (component 4 in http://wiki.squeak.org/squeak/6060) for them. So, remember that sometimes this library isn't in the server packages but in the client one.
If you have a problem compiling OpenDBX or whatever, you can write to the OpenDBX list:https://lists.sourceforge.net/lists/listinfo/libopendbx-devel/. All of us are subscribed to that list, so we'll see the message and try to help you.
We have prepared a document (It will then be in this wiki) with all the common problems people have when trying to compile openDBX with different backends and OS. You should read (it will be very helpful for you) it from here: http://www.assembla.com/spaces/Proyecto-Proyecto/documents/cW1J8Mx40r3Rq-eJe5afGb/download/openDBXtutorial_v2.0.pdf
Testing (if you compile it)
After compiling and installing OpenDBX, there is a good way to see if everything is working as expected. Go to the directory where you uncompressed OpenDBX. Do cd test and then, for example ./odbxtest -b pgsql -h localhost -p 5432 -d myDatabase -u myUser -w myPass where 'pqsql' is the specific name for postgres backend. If you compiled it with other backend you must test it with that in particular. This test will create tables, insert, select, update and delete data. Finally, It will drop all tables.
If you have an error executing this test, it means there is a problem with OpenDBX, so you won't be able to use SqueakDBX till you fix that.
OpenDBX and FFI
You can have a common problem which is that SqueakDBX, trough FFI, cannot find openDBX library. It can be this: If you compile openDBX by yourself, the operation system will put all those files in the directory associated for things compiled by the user. For example, in most Linux distributions, it is /usr/local/lib. However if you install it from binaries (.deb, .rpm or whatever) it will put the installed application in /usr/lib. We have situations when FFI was looking in one of those directories or in different order. Here you can do two things: copy all the files of openDBX to the other directory, or create symbolic links. The openDBX compilation resulted files and directories are:
- directory /usr/local/lib/opendbx with 5 files inside per backend you compile
- some libopendbx(10) in /usr/local/lib
- file /usr/local/lib/pkgconfig/opendbx.pc
If you try to run any test and you get a 'unable to find function address' this means FFI doesn't find the openDBX shared library. In this case, there are some things you can do:
- Evaluate 'OpenDBX current'. You should have a subclass of OpenDBX that represents your OS. For example, if you are in Mac OS, you must have an OpenDBXMacOSX instance.
- check PATH variable: This depends on the OS. For example, in Linux you should have: /usr/lib and /usr/local/lib.
- check DYLD_LIBRARY_PATH or LD_LIBRARY_PATH variable. For example, in Linux you should have: /usr/lib and /usr/local/lib.
- Be sure the file of the shared library has the correct name. Perhaps if you install openDBX from binaries (suppose .deb) it will create the file libopendbx.so.1. But FFI will search for libopendbx.so. So, in this case, the simpler solution is to copy and rename (or just rename) libopendbx.so.1 to libopendbx.so and should work like a charm.
Problems with Mac OS:
- Check the property SqueakPluginsBuiltInOrLocalOnly in Info.plist de la VM. This should be in false.
- Put a symlink to the opendbx library inside the Squeak directory. In other words create the link in the Resources directory of the SqueakVM package:
cd Squeak\ 3.8.18beta3U.app/Contents/Resources/
ln -s /usr/local/lib/libopendbx.dylib opendbx
- http://smalltalkconsulting.com/html/squeakinfoplist.html
Set SqueakDebug to 1 and it will print lots of information about where it's trying to find the indicated library. You will need to start the VM from a terminal session command line to see the log messages. When SqueakPluginsBuiltInOrLocalOnly is false we look in more places.
Environment variables it uses are:
SQUEAK_PLUGIN_PATH
VM_LIBDIR
VM_X11DIR
We also hunt in the .apps resources folder
standard Plugins directory
the current directory ./
the vm directory
and lastly frameworks in
"/CoreServices.framework/Frameworks",
"/ApplicationServices.framework/Frameworks",
"/Carbon.framework/Frameworks",
When SqueakPluginsBuiltInOrLocalOnly is true we only look in
the.apps resources folder
standard Plugins directory
and lastly frameworks in
"/CoreServices.framework/Frameworks",
"/ApplicationServices.framework/Frameworks",
"/Carbon.framework/Frameworks",