Install

nanodbc is distributed in form of source code package.

nanodbc is intentionally small enough that you can drag and drop the header and implementation files into your project and run with it.

Binary packages, if available, are provided and supported by third-parties, developers and maintainers of numerous package managers.

Source

You can build nanodbc library, build and run tests using CMake.

git clone https://github.com/nanodbc/nanodbc.git
cd nanodbc
mkdir build
cd build
cmake ..
cmake --build .
ctest -V --output-on-failure

Requirements

  • C++ compiler with C++11/C++14 support

  • CMake 3.0.0 or later

  • ODBC SDK (unixODBC, iODBC, Windows SDK)

Optionally, you will also need:

  • ODBC drivers, depending on DBMS you want to target (eg. running tests).

  • Boost.Locale, alternative for Unicode conversion routines.

  • libc++, alternative C++11 and later implementation.

Build

Although detailed build process depends on CMake generator used, number of common targets are always available.

For example, CMake configuration using Makefiles generator:

cd nanodbc
mkdir build
cd build
cmake -G "Unix Makefiles" [options] ..
make          # creates shared library
make nanodbc  # creates shared library
make tests    # builds the tests
make test     # runs the tests
make check    # builds and then runs tests
make examples # builds all the example programs
make install  # installs nanodbc.h and shared library

CMake OPTION and cache entry variables are available to specify with -D switch to enable or disable nanodbc built-in features.

All boolean options follow the CMake OPTION default value convention: if no initial value is provided, OFF is used.

List of CMake options specific to nanodbc, in alphabetical order:

NANODBC_DISABLE_ASYNCboolean

Disable all async features. May resolve build issues in older ODBC versions.

NANODBC_DISABLE_EXAMPLESboolean

Do not build examples.

NANODBC_DISABLE_INSTALLboolean

Do not generate install target.

NANODBC_DISABLE_LIBCXXboolean

Do not use libc++, if available on the system.

NANODBC_DISABLE_TESTSboolean

Do not build tests. Do not generate test and check targets.

NANODBC_ENABLE_BOOSTboolean

Use Boost for Unicode string convertions (requires Boost.Locale). Workaround to issue #44.

NANODBC_ENABLE_UNICODEboolean

Enable Unicode support. nanodbc::string becomes std::u16string or std::u32string.

NANODBC_ENABLE_WORKAROUND_NODATAboolean

Enable SQL_NO_DATA workaround #33.

NANODBC_ODBC_VERSIONstring

Force ODBC version to use. Possible values are SQL_OV_ODBC3 or SQL_OV_ODBC3_80. Default value is SQL_OV_ODBC3_80, if available.

Standard CMake options are also available, for example:

BUILD_SHARED_LIBSboolean

Build nanodbc as A shared library. Default value is OFF.

If you are not using CMake to build nanodbc, you will need to set the options, using the corresponding names, as preprocessor defines yourself.

Test

Tests use the Catch test framework. CMake automatically fetches the latest version of Catch for you at build time.

Once nanodbc build is ready, use ctest to run tests in CMake generator-agnostic way:

ctest -V --output-on-failure

Alternatively, build test target (eg. make test).

Binaries

This section aim to list all known binary packages of nanodbc.

If you maintain binary package of nanodbc and you’d like to list it here, please submit new entry via pull request or open an issue

Windows