Static Linking¶
To statically link and use multiple drivers, the following limitations hold:
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
You must provide
fmt
andnanoarrow
dependencies. (This may be relaxed in the future.)You must explicitly link all the required transitive dependencies. This is:
libpq
for PostgreSQLsqlite3
for SQLiteadbc_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.
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.