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

Nick Gorham nick at lurcher.org
Sat Jul 31 02:11:29 BST 2010

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.


More information about the unixODBC-dev mailing list