[unixODBC-support] Building ODBC sample on Ubuntu

ML d4t4full at gmail.com
Mon Mar 14 11:49:17 GMT 2016


Regarding packages, I searched Ubuntu's package search and found this
page: http://packages.ubuntu.com/trusty/unixodbc-bin
At the bottom there are two links to browse files in the package. One of
them is "ODBCManageDataSourcesQ4".
So, the package you want to install is "unixodbc-bin".

The hard way I learnt that "ODBCConfig" was replaced by
"ODBCCreateDataSourceQ4" (wizard-like) and "ODBCManageDataSourcesQ4".
Remember to prefix any of those with "sudo" if you will create/edit any
ODBC system setting.


*On 2016-03-12 15:44, Martin J. Evans wrote:*
> You only need the unixodbc package and the unixodbc-dev package. To
> compile you need -Idir where dir is where sql*.h are located. To link
> you need -Ldir where dir is where libodbc.so <http://libodbc.so>
> libodbcinst.so <http://libodbcinst.so> are located and a -lodbc and
> -lodbcinst. So cc -I/dir -Ldir xxx.c -Ldir -lodbc -lodbcinst should do it.
> Martin J. Evans
> *On 12 Mar 2016, at 18:34, David Adler <**dadler at adtechgeospatial.com
> <mailto:dadler at adtechgeospatial.com>**> wrote:*
>     I just want to run a test program using ODBC calls on Ubuntu but can't 
>     find any information on what includes to use or how to link. Is there a 
>     sample makefile? I've used ODBC on Windows with no problem.
>     Also unixodbc documentation refers to ODBCConfig but this doesn't seem 
>     to be on my system.
>     There are also references to the package unixodbc-gui-qt but apt-get 
>     can't find it.
>     This is the program I'm trying to run:
>     #include <stdio.h>
>     #include <sql.h>
>     #include <sqlext.h>
>     main() {
>        SQLHENV env;
>        char driver[256];
>        char attr[256];
>        SQLSMALLINT driver_ret;
>        SQLSMALLINT attr_ret;
>        SQLUSMALLINT direction;
>        SQLRETURN ret;
>        SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
>        SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
>        direction = SQL_FETCH_FIRST;
>        while(SQL_SUCCEEDED(ret = SQLDrivers(env, direction,driver, sizeof(driver), &driver_ret, attr, sizeof(attr),
>     &attr_ret))) { direction = SQL_FETCH_NEXT; printf("%s - %s\n",
>     driver, attr); if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata
>     truncation\n"); } } It compiles but fails with
>     user at ubuntuvm:~/odbc$ make Linking CXX executable odbctest
>     CMakeFiles/odbctest.dir/odbctest.cpp.o: In function `main':
>     /home/user/odbc/odbctest.cpp:14: undefined reference to
>     `SQLAllocHandle' /home/user/odbc/odbctest.cpp:15: undefined
>     reference to `SQLSetEnvAttr' /home/user/odbc/odbctest.cpp:18:
>     undefined reference to `SQLDrivers' collect2: error: ld returned 1
>     exit status make[2]: *** [odbctest] Error 1 make[1]: ***
>     [CMakeFiles/odbctest.dir/all] Error 2 make: *** [all] Error 2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20160314/6e897c67/attachment.html>

More information about the unixODBC-support mailing list