[unixODBC-support] How to change the CONFIGURATION pathof odbcinst.ini and odbc.ini

Jeff Martin JMartin at telecomsys.com
Wed Mar 21 16:21:05 GMT 2007

shiv kumar wrote:

> I have built the UnixODBC and FreeTDS using the configuration path
> /build/unixODBC and /build/FreeTDS. Then I have copied completely
> these installation directories ( unixODBC and FreeTDS ) to another
> system under the directory "/export/ODBC". I have faced a lot of
> problems in connecting the isql with DSN name and finally when I
> have executed the following command it is showing the below result:
> bash-2.04$ odbcinst -j unixODBC 2.2.11 DRIVERS............:
> /build/unixODBC/etc/odbcinst.ini SYSTEM DATA SOURCES:
> /build/unixODBC/etc/odbc.ini USER DATA SOURCES..: /u/ask/.odbc.ini
> From the result I found that the unixODBC is using the hard coded
> path
> (during the build which I supplied) to find the odbcinst.ini. Also I
> am able to confirm this using the below grep. I am expecting the
> odbc*.ini should be accessed from the "/export/ODBC/unixODBC/etc"
> directory. For the user DSN it is taking the .odbc,ini from the HOME
> directory. Can any one please let me know how to change this
> CONFIGURATION path of odbcinst.ini and odbc.ini without building the
> libraries and executables again?

Nick Gorham wrote:

> You can't change it its built into the libraries you created.
> However you can override it at runtime. set ODBCSYSINI to be the
> path of the directory that contains your system odbc.ini and
> odbcinst.ini file or ODBCINI to be the path and filename of your
> odbc.ini

We discovered a way to do what shiv wants without relying on
Using $ODBCSYSINI works, but it's annoying to have to remember to
always set it.  You can get what you want by running the 'configure'
script and then 'make' like this (assuming that you've copied the 
distribution into /build/ODBC)

  $ cd /build/ODBC
  $ ./configure --prefix=/export/ODBC
  $ make
  $ make install

Using --prefix has two effects.  First, during the plain 'make' which
builds everything, the --prefix effects the "hardcoded" value in the
executables so that it will be [prefix]/etc/odbc.ini.  Second, during
the 'make install', the --prefix tells 'make install' where to put
everything.  So with this technique you don't have to manually copy

We actually took it one step further.  We wanted the default odbc.ini
to be searched for in /etc/odbc.ini.  But we wanted to install to a 
different location than /etc.  We were able to get this result by 
building like this:

  $ ./configure --sysconfdir=/etc
  $ make
  $ make install DESTDIR=/export/ODBC

Using --sysconfdir with configure (rather then prefix) only effects the
location that unixODBC will search, so that it will search in
/etc/odbc.ini.  Then using the DESTDIR on the 'make install' tells it
where to actually copy the files.  Finally, we can still use
$ODBCSYSINI to "override" the default location of /etc/odbc.ini

We discovered this technique by looking at all the options that the
unixODBC configure scripts supports.  You can see them with this

  $ ./configure --help

There may be some other options you might be interested in.

The information contained in this message may be privileged and/or confidential. If you are not the intended recipient, or responsible for delivering this message to the intended recipient, any review, forwarding, dissemination, distribution or copying of this communication or any attachment(s) is strictly prohibited. If you have received this message in error, please so notify the sender immediately, and delete it and all attachments from your computer and network.

More information about the unixODBC-support mailing list