Wednesday, May 21, 2008

Installing VMware Server Console in Hardy Heron 8.04

Here are the steps I followed while trying to install VMware Server Console on Hardy:
  • Install some prerequisitives: sudo apt-get install build-essential linux-headers-`uname -r` xinetd
  • Download the VMware Server Linux client package, which is a zip that contains the following components components:
    - Linux VMware Server Console (.tar and .rpm)
    - Perl scripting API for Linux (.tar)
    - Programming API (.tar)
  • Unzip the downloaded file.
  • Extract the file VMware-server-console-1.0.4-56528.tar.gz.
  • Enter the directory it was extracted into and run sudo ./vmware-install.pl
  • The installer will ask some questions. Choose the default answer on all of them.
  • Running vmware-server-console will fail with the following error messages:
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4' not found (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
    /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6)
  • Create the following links:
    sudo ln -sf /lib/libgcc_s.so.1 /usr/lib/vmware-server-console/lib/libgcc_s.so.1/libgcc_s.so.1
    sudo ln -sf  /usr/lib/libpng12.so.0 /usr/lib/vmware-server-console/lib/libpng12.so.0/libpng12.so.0
    

Monday, May 5, 2008

Installing, configuring and using ODBC on ubuntu

I wanted to use an ODBC-MySQL bridge on my linux box. Here are the steps I followed.
  • First of all, unixodbc comes installed on ubuntu. Otherwise you can install the package called unixodbc.
  • I downloaded and installed the ODBC connector from the MySQL website. I downloaded the rpm package, converted it to a deb with alien and installed it with dpkg.
  • I also found and installed these packages in the ubuntu repositories: mysql-connector-odbc and libmyodbc. There is probably some redundancy in this step and the previous one, but at least I didn't have any conflict issues and everything worked in the end.
  • Now, unixodbc relies on two files: /etc/odbcinst.ini and ~/.odbc.ini. The first one holds a registry with ODBC drivers for different database systems. The installer for the MySQL driver (the one from the MySQL website) registers the driver with this file, so you don't need to do that manually. The file should look like this:
    [MySQL]
    DRIVER          = /usr/lib/libmyodbc3.so
    SETUP           = /usr/lib/libmyodbc3S.so
    UsageCount              = 1
    
    Make sure the location of the drivers is the correct one.
  • The .odbc.ini is used for declaring datasources. Actually this file declares datasources on a per-user basis. Global datasources can be configured in the file /etc/odbc.ini. An entry on these files should look like this:
    [test]
    DRIVER = MySQL
    SERVER = localhost
    DATABASE = mysql
    USER        =root 
    PASSWORD    =
    PORT        = 3306
    SOCKET = /var/run/mysqld/mysqld.sock
    
    Needless to say that the DRIVER name should must the name of the driver, as it was declared on /etc/odbcinst.ini.
  • As you can see I also had to explicitly define the mysql socket. This was because the location of the mysql socket in ubuntu is different than in other linux systems. By default, unixodbc uses the location /tmp/mysql.sock, so you can either explicitly specify the socket location as above, or just create a link:
    sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
  • Now you can test the connection using
    isql -v test
    You should get a message like this:
    +---------------------------------------+
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    +---------------------------------------+
    followed by an SQL prompt.
  • Finally this is some java code that uses this datasource:
    // There are two ways we can address a datasource: 
    // either with the DNS of a correctly configured ODBC datasource, 
    // or by providing all the database information.
         Connection conn = java.sql.DriverManager.getConnection(
                 //"jdbc:odbc:;DRIVER={MySQL};SERVER=localhost;DATABASE=mysql;",
                 "jdbc:odbc:test",
                 "root",
                 "");