3.13. Using ODBC

This section describes how ODBC works within Wine and how to configure it.

The ODBC system within Wine, as with the printing system, is designed to hook across to the Unix system at a high level. Rather than ensuring that all the windows code works under wine it uses a suitable Unix ODBC provider, such as UnixODBC. Thus if you configure Wine to use the built-in odbc32.dll, that Wine DLL will interface to your Unix ODBC package and let that do the work, whereas if you configure Wine to use the native odbc32.dll it will try to use the native ODBC32 drivers etc.

3.13.1. Using a Unix ODBC system with Wine

The first step in using a Unix ODBC system with Wine is, of course, to get the Unix ODBC system working itself. This may involve downloading code or RPMs etc. There are several Unix ODBC systems available; the one the author is used to is unixODBC (with the IBM DB2 driver). Typically such systems will include a tool, such as isql, which will allow you to access the data from the command line so that you can check that the system is working.

The next step is to hook the Unix ODBC library to the wine built-in odbc32 DLL. The built-in odbc32 (currently) looks to the environment variable LIB_ODBC_DRIVER_MANAGER for the name of the ODBC library. For example in the author's .bashrc file is the line:

export LIB_ODBC_DRIVER_MANAGER=/usr/lib/libodbc.so.1.0.0
        

If that environment variable is not set then it looks for a library called libodbc.so and so you can add a symbolic link to equate that to your own library. For example as root you could run the commands:

# ln -s libodbc.so.1.0.0 /usr/lib/libodbc.so
# /sbin/ldconfig
        

The last step in configuring this is to ensure that Wine is set up to run the built-in version of odbc32.dll, by modifying the DLL configuration. This built-in DLL merely acts as a stub between the calling code and the Unix ODBC library.

If you have any problems then you can use WINEDEBUG=+odbc32 command before running wine to trace what is happening. One word of warning. Some programs actually cheat a little and bypass the ODBC library. For example the Crystal Reports engine goes to the registry to check on the DSN. The fix for this is documented at unixODBC's site where there is a section on using unixODBC with Wine.

3.13.2. Using Windows ODBC drivers

Native ODBC drivers have been reported to work for many types of databases including MSSQL and Oracle. In fact, some like MSSQL can only be accessed on Linux through a Winelib app. Rather than just copying DLL files, most ODBC drivers require a Windows-based installer to run to properly configure things such as registry keys.

In order to set up MSSQL support you will first need to download and run the mdac_typ.exe installer from microsoft.com. In order to configure your ODBC connections you must then run CLICONFG.EXE and ODBCAD32.EXE under Wine. You can find them in the windows\system directory after mdac_typ runs. Compare the output of these programs with the output on a native Windows machine. Some things, such as protocols, may be missing because they rely on being installed along with the operating system. If so, you may be able to copy missing functionality from an existing Windows installation as well as any registry values required. A native Windows installation configured to be used by Wine should work the same way it did when run natively.

Types successfully tested under wine:

DB TypeUsefulness
MS SQL100%

Please report any other successes to the wine-devel mailing list.