[unixODBC-support] Problem with compiling simple ODBC program

Nick Gorham nick at easysoft.com
Wed Jul 28 23:15:11 BST 2004

Lebogang Masenya wrote:
> i have just installed unixODBC and took the simple example on the
> www.unixodbc.org site with no changes for testing. but when i compile the
> programme with gcc, it gives me compile time errors saying  "undefined
> reference to <ODBC Methods>" where
> <ODBC Method> = SQLAllocHandle, SQLSetEnvHandle, SQLFreeHandle etc,etc
> my first guess was that it does not find the shared object libraries that
> are installed in /usr/local/lib by default. so i eddited the ld.so.conf file
> adding the /usr/local/lib and then running ldconfig. But it still gives me
> the same errors.
> What could be the problem with this, i have been strugling with this for a
> while please help.
> i am running
> gcc version 3.2.2
> on
> redhat linux 9.0


You need to link your app to the driver manager, this provides the API, 
and then calls the drivers for you.

Just add -lodbc to the link/compile line, and if needed -L/usr/local/lib 
-lodbc if the defaulr search doesn't find them. the changes to 
ld.so.conf is for the run time to find the lib, what you needed was to 
instruct the compiler at build time where to find the api.

Nick Gorham
Easysoft Limited

More information about the unixODBC-support mailing list