27

I am on an up-to-date Ubuntu 12.04 system. I have unixodbc (v2.2.14 from ubuntu repos), MySQL and its relevant drivers installed. Also connected to a valid DSN. Verified by issuing isql DBName UName passwd.

I am trying to compile a C application that interacts with the database using ODBC. Almost everywhere I searched seemed to indicate that I should have "sql.h" installed somewhere. A find / -iname sql.h -print showed I don't have it.

So my question is: where is it? Did something go wrong with the install (no errors were reported though)? And what steps do you recommend? Reinstallation? Compilation from source code (the latest version?)?

luchaninov
  • 6,792
  • 6
  • 60
  • 75
Richard
  • 528
  • 1
  • 5
  • 15

1 Answers1

65

You need to install the unixodbc-dev package to get the development header files.

sudo apt-get install unixodbc-dev

The -dev packages contain the require header files required to compile and build programs using these headers to make calls to the library. The library files themselves would be part of the regular package i.e. unixodbc in your case.

If you want to know which package provides a certain file, you could use apt-file:

sudo apt-file update
sudo apt-file find sql.h
Tuxdude
  • 47,485
  • 15
  • 109
  • 110
  • Thanks a lot Tuxdude. I knew it was something quite trivial. And thanks for the tip on `apt-file`. Makes searching easier – Richard Mar 16 '13 at 10:40
  • 1
    As an aside, for future viewers of the question `pkg-config` can help find the relevant include directories, and libraries for use at compile time and link time. Refer the man page for more details. Note that it must "know" about them. Library packages from repos usually are configured to install in manner so that it makes "known" the details to `pkg-config` – Richard Apr 17 '13 at 18:54
  • 1
    FYI, the result of running `sudo apt-file find sql.h` on Ubuntu 14.04 contains this line `unixodbc-dev: /usr/include/sql.h` – Ross Rogers May 22 '14 at 20:48
  • 3
    I faced same error on centOS 7 and resolved by `yum install unixODBC*` which has refered to https://stat.ethz.ch/pipermail/r-help/2010-April/235867.html – Rγσ ξηg Lιαη Ημ 雷欧 May 14 '16 at 06:39
  • Just for reference, a similar error is reported here: http://stackoverflow.com/a/31360218/72350, and the solution described there also works for AWS Elastic Beanstalk: `sudo yum install unixODBC-devel` – Diego Jancic Oct 18 '16 at 15:58