[unixODBC-support] Problem with compiling simple ODBC program

Martin J. Evans martin at easysoft.com
Wed Jul 28 21:17:00 BST 2004

You haven't said how you are compiling your program. /etc/ld.so.conf defines
what the dynamic linker does at run time - not link time. Assuming your program
is odbc.c

gcc -o myprogram odbc.c -I/usr/local/include -L/usr/local/lib -lodbc

should do it. The -L tells the linker where to look for libraries and shared
objects, the -l tells it which libraries and shared objects to consider
(libodbc.so or libodbc.a) and -I tells the compiler where to find header files
(like sql.h). It should produce myprogram which you can run at which time
/etc/ld.so.conf comes in to play.

Martin J. Evans
Development, Easysoft Ltd

Quoting Lebogang Masenya <l.masenya at ee.wits.ac.za>:

> 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
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 7/27/2004
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at mail.easysoft.com
> http://mail.easysoft.com/mailman/listinfo/unixodbc-support

More information about the unixODBC-support mailing list