Guides
Setting up an Application
The following is a step-by-step guide to setting up an application that uses ODBC to connect to a database, execute a query, and fetch the results in `C++`.  
> To install the driver as well as anything else you will need follow these [instructions](#docs:api:odbc:overview).  
#### 1. Include the SQL Header Files {#docs:guides:odbc:general::1-include-the-sql-header-files}  
The first step is to include the SQL header files:  
```cpp
#include <sql.h>
#include <sqlext.h>
```  
These files contain the definitions of the ODBC functions, as well as the data types used by ODBC. In order to be able to use these header files you have to have the `unixodbc` package installed:  
On macOS:  
```bash
brew install unixodbc
```  
On Ubuntu and Debian:  
```bash
sudo apt-get install -y unixodbc-dev
```  
On Fedora, CentOS, and Red Hat:  
```bash
sudo yum install -y unixODBC-devel
```  
Remember to include the header file location in your `CFLAGS`.  
For `MAKEFILE`:  
```make
CFLAGS=-I/usr/local/include
# or
CFLAGS=-/opt/homebrew/Cellar/unixodbc/2.3.11/include
```  
For `CMAKE`:  
```cmake
include_directories(/usr/local/include)
# or
include_directories(/opt/homebrew/Cellar/unixodbc/2.3.11/include)
```  
You also have to link the library in your `CMAKE` or `MAKEFILE`.
For `CMAKE`:  
```cmake
target_link_libraries(ODBC_application /path/to/duckdb_odbc/libduckdb_odbc.dylib)
```  
For `MAKEFILE`:  
```make
LDLIBS=-L/path/to/duckdb_odbc/libduckdb_odbc.dylib
```  
#### 2. Define the ODBC Handles and Connect to the Database {#docs:guides:odbc:general::2-define-the-odbc-handles-and-connect-to-the-database}