Author Topic: Using MyODBC (ODBC connector for MySQL)  (Read 9674 times)

Offline resander

  • Multiple posting newcomer
  • *
  • Posts: 49
Using MyODBC (ODBC connector for MySQL)
« on: April 17, 2009, 08:00:13 pm »
Anyone done this using codeblocks?

I am just trying to get it working on Ubuntu 8.10 by:

 -  sudo apt-get install iodbc   (to get an ODBC managaer that configures Datasource names etc)
 -  sudo apt-get install libmyodbc (to get the library to /usr/lib/odbc/libmyodbc.so)

Then put /usr/lib/odbc/libmyodbc.so into Link-library list of Codeblocks via Projects->Buildoptions->select Linker tab and the Add button.

The db application linked OK, but the program stopped before entry to main outputting message '/home/ken/projects/ls/bin/Debug/ls: error while loading shared libraries: libmyodbc3_r-3.51.15.so: cannot open shared object file: No such file or directory'.

The sudo apt-get install libmyodbc does not generate a file named libmyodbc3_r-3.51.15.so, so I downloaded a fairly recent ODBC .gz file from MySQL.com and installed. It contained several lib-files, one called libmyodbc3_r-3.51.27.so that I renamed to libmyodbc3_r-3.51.15.so. The program still did not go into main. The same message appeared.

I am going around in circles here, so would be grateful for hints. 

Offline resander

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: Using MyODBC (ODBC connector for MySQL)
« Reply #1 on: May 17, 2009, 06:30:57 pm »
I actually decided to use the unixODBC linux package.
This is either preinstalled for Ubuntu or available via Synaptic manager.
Info available at unixodbc.org.

unixODBC contains a Driver manager that is used at runtime to forward ODBC sql calls to db product drivers.

It also contains a GUI that allows a user to specify ODBC drivers and and dsns (data source names). The GUI only writes text to the odbc ini files, so there is no need to use it. Using a text editor is ok too.

To link to ODBC driver manager put /usr/lib/libodbc.so.1
into Project->Build Options->Linksettings

Then set the odbcinst.ini and odbc.ini files as follows:

/etc/odbcinst.ini
[MYSQL]
Driver      = /usr/local/lib/libmyodbc3.so
Description   = MyODBC 3.51 Driver

/etc/odbc.ini
[yourdsn]
Driver      = MYSQL
SERVER      = localhost
PORT        =
USER        = root
Password    =
Database    =
OPTION      = 3
SOCKET      = /var/run/mysqld/mysqld.sock