Static Linking

To statically link and use multiple drivers, the following limitations hold:

  1. You must build with these CMake options [1]:

    • -DADBC_BUILD_STATIC=ON

    • -DADBC_DEFINE_COMMON_ENTRYPOINTS=OFF

    • -DADBC_WITH_VENDORED_FMT=OFF

    • -DADBC_WITH_VENDORED_NANOARROW=OFF

  2. You must provide fmt and nanoarrow dependencies. (This may be relaxed in the future.)

  3. You must explicitly link all the required transitive dependencies. This is:

    • libpq for PostgreSQL

    • sqlite3 for SQLite

    • adbc_driver_common, adbc_driver_framework, fmt, nanoarrow, and the C++ standard library for either PostgreSQL or SQLite.

    • To link the C++ standard library, the easiest thing is to just use the C++ linker, even if the code itself is in C, e.g.

      set_target_properties(myapp PROPERTIES LINKER_LANGUAGE CXX)
      
    • Go-based drivers (BigQuery, Flight SQL, Snowflake) have no transitive dependencies.

  4. You cannot link more than a single Go-based driver. See golang/go#20639, StackOverflow #67243572, and StackOverflow #34333107 for a discussion of the issues involved. (This may be relaxed in the future by providing a way to build a single driver library with all driver implementations included.)

An example of this can be seen with cpp_static_test.sh and c/integration/static_test in the source tree.