[unixODBC-dev] Building a single static unixODBC application + Postgres driver

Peter Harvey pharvey at peterharvey.org
Sat Jul 31 04:30:45 BST 2010


If you need to use multiple ODBC drivers then it sounds like you will 
need to dynamically link to the drivers as needed (essentially doing 
some of what the Driver Manager does) or simply use the Driver Manager.

In the latter case you can package all of the ODBC stuff with your 
application and then install the ODBC bits as required (read; if they 
are not already installed on the system)... but I would recommend simply 
making the ODBC bits a requirement for your application (as is usually 
done). .

--
Peter


Sebastian Wess wrote:
> Nick-
>
> > Well, my first suggestion would be to bipass the driver manager,
> > what are the project requirements that prevent that?
>
> The requirement is that I will eventually need to be able to ship the 
> binary with multiple drivers (Postgres and MySQL) and use the ODBC 
> interface to talk to both of them. So am I correct in understanding 
> that this is going to be a non-starter without some code modification 
> of the driver manager? I.e., there's no magic configure flag that will 
> let me have everything bundled in one big executable?
>
>
> --- On *Sat, 7/31/10, Nick Gorham /<nick at lurcher.org>/* wrote:
>
>
>     From: Nick Gorham <nick at lurcher.org>
>     Subject: Re: [unixODBC-dev] Building a single static unixODBC
>     application + Postgres driver
>     To: "Development issues and topics for unixODBC"
>     <unixodbc-dev at mailman.unixodbc.org>
>     Date: Saturday, July 31, 2010, 1:11 AM
>
>     Sebastian Wess wrote:
>     > I need to distribute a single application binary to connect to
>     Postgres (or other databses) using unixODBC with no external
>     dependencies. Is it possible to use the unixODBC driver manager
>     when the driver itself is statically linked into the executable?
>     It seems like unixODBC makes use of dlopen() to dynamically link
>     in the driver at runtime, and I don't see how to get around that.
>     >
>     > To start I would like to get a version of isql built that
>     statically links in the Postgres driver and see if I can use that
>     to connect. I've tried building with "./configure --enable-drivers
>     --enable-static --enable-shared=no && make" and then manually
>     re-linking isql with the Postgres driver with "gcc -g -O2 -pthread
>     -o isql isql.o  ../DriverManager/.libs/libodbc.a
>     ../extras/.libs/libodbcextraslc.a
>     ../Drivers/Postgre7.1/.libs/libodbcpsql.a -ldl -lpthread
>     -pthread", but odbcinst.ini seems to still require that I list a
>     separate file in the "Driver" setting.
>     >
>     > Is what I'm trying to do even possible?
>     >
>     >
>     > P.S. Unfortunately I can't just bypass unixODBC and use the
>     Postgres driver directly due to project requirements.
>     >
>     >
>     Well, my first suggestion would be to bipass the driver manager,
>     what are the project requirements that prevent that? Without
>     dynamic loading you are going to have problems with name
>     collisions if you try and use the driver manager and a driver
>     without run time linking.
>
>     You do have the code so you could make changes, though be aware
>     you need to comply with the terms of the LGPL if you distribute
>     the result and make the changes available.
>
>     -- Nick
>     _______________________________________________
>     unixODBC-dev mailing list
>     unixODBC-dev at mailman.unixodbc.org
>     </mc/compose?to=unixODBC-dev at mailman.unixodbc.org>
>     http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
>
>
>
> _______________________________________________
> unixODBC-dev mailing list
> unixODBC-dev at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
>    



More information about the unixODBC-dev mailing list