Free Tool Downloads, Community Forum,
 FAQs and Developer Resources

Order Interop Toolworks 2.3
Order the entire /Tools collection on
one CD for $40 + $3 shipping
or download the .ISO image and create your own CD for $30.              More Info

  [Interop Home] [Join] [Contact Us] [Site Map] [Privacy]

The iODBC Driver Manager Detailed Overview

Copyright (C) 1995 by Ke Jin
Copyright (C) 1996-2004 by OpenLink Software
All Rights Reserved.


Welcome to the iODBC driver manager maintained by OpenLink Software ( This kit will provide you with everything you need in order to develop ODBC-compliant applications under Interix without having to pay royalties to other parties.

This kit consists of a number of parts:

  • The iODBC driver manager. This is a complete implementation of an ODBC driver manager, released under either the GNU Library General Public License or the BSD License. We fully comply with these licenses by giving you this product in source form (as well as the binary form). You can download the latest version of the driver manager from

  • A simple example, iodbctest.c, which gives you a command-line interface to SQL. You can fit this to your purposes, but at the very least this is useful for verification of your ODBC installation.

You can use either part stand-alone, if you wish.

An ODBC driver is still needed to affect your connection architecture. You may build a driver with the iODBC components or obtain an ODBC driver from a commercial vendor. OpenLink Software produces cross-platform commercial drivers as well as maintaining the iODBC distribution: evaluation copies may be obtained via download from Any ODBC-compliant driver will work with the iODBC Driver Manager.

See also the iODBC website,, for more pointers to various ODBC drivers.

Installation of run-time distribution

There is both a source and binary distribution available from the Interop Systems database tools area. <<<<

If you are building from the source, first read the README.interix file.

Ensure that LD_LIBRARY_PATH includes /usr/local/iodbc/lib.

The subdirectory "interix" holds copies of the configuration files edited for compilation with gcc under SFU/Interix 3.5. Simply copy these files over the distribution version, and run

        CFLAGS=-D_ALL_SOURCE ./configure --prefix=/usr/local/iodbc
        gmake install

Contribution of changes, patches and updates.

While not mandated by the BSD license, any patches you make to the iODBC may be contributed back into the iODBC project at your discretion. Contributions will benefit the Open Source and Data Access community as a whole. Submissions may be made at

Patches that are SFU specific can be directed to .

iODBC driver manager platform availability

The iODBC driver manager has been ported to following Unix platforms:

Interop Systems Inc.

 UNIX Tools Community

database connectivity

Accessing SQL Server and Other Databases from SFU 3.5

Microsoft Windows Services For UNIX 3.5 has no built-in libraries or interfaces for accessing relational databases stored on other platforms. Nor is it possible to access a Microsoft SQL Server database on the same system, running in the Windows subsystem.

However, there are several packages that can ease this problem. Our Database Tools area contains recent builds of the following (along with source files and a Readme.Interix with each source file):

  • iODBC - another popular Open Source ODBC driver manager.  To download, visit the Tool Warehouse page.  This page now requires a login name and password.  If you are not already a member of our UNIX Tools Community, you can join here.

  • unixODBC - a popular Open Source ODBC driver manager.  To download, visit the Tool Warehouse page.  This also serves as the ODBC-ODBC bridge client from Easysoft, allowing access to any ODBC driver in Windows. See Easysoft ODBC-ODBC Bridge.

  • FreeTDS - an Open Source implementation of the Tabular Data Stream protocol used to access SQL Server and Sybase databases, including dblib, ctlib and an ODBC driver. To download, visit the Tool Warehouse page.

  • Perl - the latest stable release (5.8.3) of the most popular scripting language, complete with the DBI database interface module, DBD::ODBC for connecting via ODBC, and DBD::Sybase to connect to any Sybase or SQL Server using FreeTDS.  To download, visit the Tool Warehouse page.

All of these applications and libraries are built with support for threads enabled by default.

Note: Special thanks to our database consulting partner, MSB Associates, for porting these tools, and thanks to Microsoft for providing the funding.  This is a new page within our UNIX Tools Community so in keeping with the "community" spirit please post your comments, questions, examples and bugs in the new area of the UNIX Tools Forum.  If you require one-on-one assistance, please refer to our Services page for our telephone and email support packages.

ODBC Connectivity

Two ODBC driver managers are included in the database tools area: unixODBC and iODBC. These are both equivalent, and can basically be interchanged. However, where other tools in the Interop DB tools warehouse are linked against an ODBC driver manager, it is the unixODBC manager that is used in the binary package.

Both driver managers can be installed simultaneously ... one will be in /usr/local/unixODBC, the other in /usr/local/iodbc.

When building applications, ensure that LD_LIBRARY_PATH includes the preferred manager (i.e. ensure that it includes either /usr/local/unixODBC/lib or /usr/local/iodbc/lib). Also, pass the relevant include directory to the build process (e.g. -I/usr/local/unixODBC/include).

Almost all current Open Source packages that use ODBC include a switch to select the relevant driver manager at build time, e.g. CFLAGS=-D_ALL_SOURCE ./configure --with-unixodbc=/usr/local/unixODBC

The iODBC Driver Manager

The iODBC driver manager controls access to ODBC drivers. Two configuration files are used: odbcinst.ini, which describes the drivers (e.g. the FreeTDS ODBC driver, or the ODBC-ODBC bridge client driver), and odbc.ini, which describes the data sources (the actual database instances you want to connect to).

Details are in the detailed overview below.

Further information is available at

The unixODBC Driver Manager

The unixODBC driver is very similar to the iODBC driver manager above, and is the driver manager used in the binary builds of all the SFU 3.5 database tools.  It is also the client for Easysoft's ODBC-ODBC BridgeWith the ODBC-ODBC Bridge you can access any database which has a Windows ODBC driver. One license of Easysoftís ODBC-ODBC Bridge, which incorporates the unixODBC Driver Manager, gives SFU/Interix users a universal ODBC solution.

As an example, say the SFU / Interix application needs access to a remote Oracle database on a UNIX or Linux box. Oracle does not provide OCI support for Interix. However, there are Oracle drivers available for Windows so any Windows machine can act as the client and the gateway. Easysoftís ODBC-ODBC Bridge Server (a commercial product) is installed on the gateway and the ODBC-ODBC Client (unixODBC) on the end userís machine. In fact, the client and the gateway can be the same physical server. When you need to access another database (say MS SQL Server, MS Access, Excel) you simply configure the appropriate datasource on the gateway. No action is required on the UNIX system.  See diagram and pricing.

The format of the odbc.ini file is almost identical to that of the iODBC driver manager. Details of these configuration files is given below.

Although unixODBC contains a graphical administrator tool, this is not built by default, as it requires libgtk in order to operate.  (GTK+ is available in the Tool Warehouse.)

Further information is available at and


The Tabular Data Stream (TDS) protocol is used to communicate with either Sybase or Microsoft SQL Server databases.

FreeTDS is an Open Source implementation of this protocol, and contains several Application Program Interfaces that use it.


An implementation of Microsoft's db-lib API. While the core functions are reasonably complete and work well, the cursor additional APIs have not yet been implemented.  [We are considering a project to build the cursor library for dblib.  Let us know if this is important to you. ]


An implementation of Sybase's Open Client library. Although this library was originally designed for Sybase, it works well with SQL Server.


An ODBC driver that can operate under either unixODBC or iODBC to communicate with either a Sybase or SQL Server database.

There are several different versions of the TDS protocol, and when setting up the configuration file it is important to understand these differences:




Microsoft SQL Server 2000


Microsoft SQL Server 7.0


Sybase Adaptive Server Anywhere 12.0 and 12.5


Ancient versions of either SQL Server or Sybase

The configuration file /usr/local/etc/freetds.conf should contain entries for your databases. Use the entries there as templates for each server type.

Further information is available at


Perl is especially complex to build correctly under SFU 3.5. There are several pitfalls an unwary or inexperienced developer can fall into.

The best approach is to use the and supplied files and edit these as appropriate. Then run $ ./Configure -der

to rebuild the makefiles etc. Then gmake to build a new binary.

Almost all the tests run by gmake test now run correctly. However, there are a number of special cases for SFU (for example, the privileged user does not have UID 1 in SFU).

In a very few cases, gmake test (or prove -b -v t/*.t) will hang after all the tests have completed successfully. It is believed that this is an issue with end-of-file signaling on pipes in Interix, and is still under investigation.

FreeTDS Configuration

The FreeTDS binary package installs into /usr/local/freetds. A configuration file, etc/freetds.conf describes the databases it can connect to (NOTE the relationship between the name in this file and that in the ODBC configuration files; the ODBC file Servername describes an entry in this file). FreeTDS supports a number of different ways of setting up the configuration files; the method described here is strongly recommended.  It is known as the "ODBC-Combined" method. It is described in more detail at The configuration file can be overridden with the environment variable FREETDSCONF.

A sample configuration file:

    # The freetds.conf file is a replacement for the original interfaces
    # file developed by Sybase.  You may use either this or the interfaces
    # file, but not both.
    # FreeTDS will search for a conf file in the following order:
    #     1) check if a file was set programatically via dbsetifile() and
    #        is in .conf format, if so use that,
    #     2) look in ~/.freetds.conf
    #     3) look in @sysconfdir@/freetds.conf
    # If FreeTDS has found no suitable conf file it will then search for
    # an an interfaces file in the following order:
    #     1) check if a file was set programatically via dbsetifile() and
    #        is in interfaces format, if so use that,
    #     2) look in ~/.interfaces
    #     3) look in $SYBASE/interfaces (where $SYBASE is an environment
    #        variable)
    # Only hostname, port number, and protocol version can be specified
    # using the interfaces format.
    # The conf file format follows a modified Samba style layout.  There
    # is a [global] section which will affect all database servers and
    # basic program behavior, and a section headed with the database
    # server's name which will have settings which override the global
    # ones.

    # Global settings, any value here may be overridden by a database
    # server specific section
            # TDS protocol version
            tds version = 4.2

            initial block size = 512

            swap broken dates = no

            swap broken money = no

            # Database server login method, if both server and domain
            # logins are enabled, domain login is tried first if a domain
            # is specified, and if that fails the server login will be used.
            try server login = yes
            try domain login = no

            # The default authentication domain, can be overridden by
            # specifying a username with a domain prefix, e.g. DOMAIN\username
    ;   nt domain = WORKGROUP

            # If the server responds with different domain try that one?
            cross domain login = no

            # Whether to write a TDSDUMP file for diagnostic purposes
            # (setting this to /tmp is insecure on a multi-user system)
    ;   dump file = /tmp/freetds.log
    ;   debug level = 10

            # Command and connection timeouts
    ;   timeout = 10;
    ;   connect timeout = 10;
    # This is a Sybase hosted database server, if you are directly on the
    # net you can use it to test.
            host =
            port = 4444
            tds version = 5.0

    # A typical Microsoft SQL Server 7.0 configuration  
    ;   host =
    ;   port = 1433
    ;   tds version = 7.0

    # A typical Microsoft SQL Server 7.0 configuration using domain logins
    ;   host =
    ;   port = 1433
    ;   tds version = 7.0
    ;   try domain logins = yes
    ;   try server logins = no
    ;   nt domain = MYDOMAIN

    # A typical Microsoft SQL Server 6.x configuration  
    ;   host =
    ;   port = 1433
    ;   tds version = 4.2

            host =
            port = 1433
            tds version = 8.0







DEC Unix(OSF/1)

3.x - 5.x

DEC Alpha





2.x - 5.x



9.x - 11.x

HP9000 s700/s800



HP9000 s300/s400


3.x - 5.x

IBM RS6000, PowerPC

Linux ELF

1.x, 2.x

x86, Itanium, PowerPC

Mac OS X





Concurrent Maxion 9200 MP



NCR 3435



DEC Alpha

SCO OpenServer




5.x, 6.x




Sun Sparc

Sun Solaris


Sun Sparc, PCx86

UnixWare SVR4.2

1.x, 2.x


Windows NT



Microsoft SFU



As the iODBC driver manager uses autoconf/automake/libtool it should be portable to most modern UNIX platforms out of the box. However if you do need to make changes to the code or the configuration files, we would appreciate you share your changes with the rest of the internet community by mailing your patches to . so we can include them for the next build.

Porting of iODBC driver manager to some non-UNIX operating systems such as Windows family(3.x, 95, NT), OS/2 and Mac Classic is supported but has not been compiled and tested recently. Of course, you need to supply a make/build file and a short LibMain for creating the iodbc.dll.

How to build iODBC driver manager:

Microsoft SFU users should follow the directions in README.interix. In particular, ensure that the environment variableCFLAGS=-D_ALL_SOURCE is set.

Mac OS X users should read the separate README.MACOSX document for more detail of porting on this platform. Otherwise:

  1. Run configure to adjust to target platform

  2. Run eagmake

  3. Run gmake install

The configure program will examine your system for various compiler flags, system options etc. In some cases extra flags need to be added for the C compiler to work properly.

e.g. on HP systems you may need:

        $ CFLAGS="-Ae -O" ./configure --prefix=/usr/local ..........<
File Hierarchy

Note that the path of the system wide odbc.ini file is calculated as follows (based on flags to ./configure):

no --prefix

default is /etc/odbc.ini









If the `--with-layout=' option is set, then the prefix and sysconfdir parameters will be changed accordingly. Currently, this parameter understands values of `gentoo', `redhat', `gnu', `debian' or `opt' (with everything going into /opt/iodbc/). If both are specified, a --prefix argument will overrule a --with-layout.

The binary package was built with

  $ ./configure --prefix=/usr/local/iodbc 
--enable-pthreads --with-iodbc-inidir=/usr/local/iodbc/etc

Further Information Sources:

  • iODBC project home page. Binaries, source, documentation

  • Source, CVS tree, mailing lists, forums, bug reports

  • OpenLink Software. Free trials and support for OpenLink's ODBC drivers.

  • Microsoft's ODBC pages.


ODBC Configuration for unixODBC and iODBC

Both the unixODBC and iODBC driver managers use two configuration files to control their operation. The first of these, odbcinst.ini describes the ODBC drivers installed on the system. It resides in the etc directory of the Driver Manager, and should be maintained by the System Administrator.

The other file, odbc.ini describes the data sources, or database instances, to which applications will be connecting. As for MS Windows, there can be two sorts of datasource, User and System.

User datasources are found in the file ~/.odbc, while system datasources are in etc/odbc.ini under the driver manager tree.

For each driver manager, the environment variable ODBCINI overrides the search for a dsn, and describes a file to be used in place of either ~/.odbc.ini or etc/odbc.ini.

It is a good idea to make symbolic links from the etc/*.ini files to the /etc directory for other programs that want to examine these files.

The relevant odbc.ini describes data sources. A data source is a section (enclosed in square parenthesis), and the attributes for a data source are given within this section. The most important attribute for each datasource is the Driver attribute. This must point to the shared library for the ODBC driver associated with the data source, or to an entry in the etc/odbcinst.ini file.

As an example, the OpenLink ODBC drivers have a number of attributes which can be set for a data source. Here is a description (with ODBC connect string tags between parenthesis):


The hostname where the database resides (HOST).


The type of server (see oplrqb.ini on the server, SVT).


Server-specific extra options. See OpenLink server documentation for agents which can use this.


The database to use (DATABASE).


Connect options for the database (OPTIONS).


The name of the user (a password cannot be specified in the UDBCINI file, UID/PWD).


A Yes/No value in order to make the connection read-only (READONLY=Y/N).


The number of records that are transferred in a single call to the server. Default is 5; maximum is 99, minimum is 1 (FBS=value).


The protocol to use. Leave set to ``TCP'' for this release.

Apart from these data source-specific settings, you may add a section called [Communications], which you may use to tune our driver further:


The time the client application will wait for the database agent to finish the request (default is 60 seconds).


The time the client application will wait for the request broker to accept of reject a database connection (default is 30 seconds).


RPC send buffer size. A value of 0 (the default) will cause the application to use system-dependent defaults.


RPC receive buffer size. A value of 0 (the default) will cause the application to use system-dependent defaults.


If set, the name of a file to which debugging output from the driver should be directed.


Driver managers and drivers use odbc.ini file or connection string when establishing a data source connection. On Windows, odbc.ini is located in Windows directory.

On UNIX, both the driver managers look for the odbc.ini file in the following sequence:

  1. check environment variable ODBCINI

  2. check $HOME/.odbc.ini (iODBC only, not unixODBC)

  3. check home in /etc/passwd and try .odbc.ini in there

  4. system-wide odbc.ini (settable at configuration time)

Item 1 is the easiest as most drivers will also look at this variable.

The format of odbc.ini( or ~/.odbc.ini ) is defined as:

        odbc.ini          ::= data_source_list

        data_source_list  ::= /* empty */
                           | data_source '\n' data_source_list

        data_source       ::= '[' data_source_name ']' '\n' data_source_desc

        data_source_name  ::= 'default' | [A-Za-z]*[A-Za-z0-9_]*

        data_source_desc  ::= /* empty */
                           | attrib_desc '\n' data_source_desc

        addrib_desc       ::= Attrib '=' attrib_value

        Attrib            ::= 'Driver' | 'PID' | 'UID' | driver_def_attrib

        driver_def_attrib ::= [A-Za-z]*[A-Za-z0-9_]*

An example of an odbcinst.ini file:

    Trace               = Yes
    TraceFile   = /tmp/sql.log

    Description = Easysoft ODBC-ODBC Bridge
    Driver              = /usr/local/easysoft/oob/client/lib/
    Setup               =
    FileUsage   = 1

    Description = FreeTDS ODBC Driver
    Driver              = /usr/local/lib/
    FileUsage   = 1

An example of an odbc.ini file:

    ;  odbc.ini
    Driver              = OOB
    Description = Easysoft ODBC-ODBC Bridge demo data source
    SERVER              =
    PORT                = 8888
    TRANSPORT   = tcpip
    TARGETDSN   = pubs
    LOGONUSER   = demo
    LOGONAUTH   = easysoft
    TargetUser  = demo
    TargetAuth  = easysoft

    Driver              = OOB
    Description = Oracle server on MSBIT
    TARGETDSN   = orasvr
    SERVER              = localhost
    TARGETUSER  = scott
    TARGETAUTH  = tiger
    LOGONUSER   = nick
    LOGONAUTH   = xxxx
    TRANSPORT   = tcpip
    PORT                = 8888

    Driver              = OOB
    Description = SQL server on THAMES
    TARGETDSN   = sqlsvr
    SERVER              = localhost
    TARGETUSER  = sa
    TARGETAUTH  = sa
    LOGONUSER   = nick
    LOGONAUTH   = xxxx
    TRANSPORT   = tcpip
    PORT                = 8888

    Driver      = TDS
    Description = SQL server via FreeTDS
    Servername  = thames


Both the unixODBC and iODBC drivers manager trace the driver's ODBC call invoked by the driver manager. Default tracing file is ./odbc.log for iODBC, or /tmp/odbc.log for unixODBC. Tracing option (i.e. on/off or optional tracing file name) can be set in odbc.ini (iODBC) or odbcinst.ini (unixODBC) file under the [ODBC] heading as:

        TraceFile = optional_trace_file
        Trace = ON | On | on | 1 | OFF | Off | off | 0

For iODBC only, if optional_trace_file is stderr or stdout, i.e.

       TraceFile = stderr


        TraceFile = stdout

The tracing message will go to the terminal screen (if it is available).