C / C++

To use TileDB C API in a program, just add #include <tiledb/tiledb.h> and specify -ltiledb when compiling, e.g.

$ gcc example.c -o example -ltiledb

To use the C++ API, add #include <tiledb/tiledb> to your C++ project instead. The TileDB C++ API requires a compiler with C++11 support, thus your project must be compiled using the C++17 standard, e.g.

$ g++ -std=c++17 example.cpp -o example -ltiledb

If TileDB was installed in a non-default location on your system, use the -I and -L options:

$ gcc example.c -o example -I<path/to/TileDB>/include -L<path/to/TileDB>/lib -ltiledb

At runtime, if TileDB is installed in a non-default location, you must make the linker aware of where the shared library resides by exporting an environment variable:

macOS
$ export DYLD_LIBRARY_PATH="<path/to/TileDB>/lib:$DYLD_LIBRARY_PATH"
$ ./example
Linux
$ export LD_LIBRARY_PATH="<path/to/TileDB>/lib:$LD_LIBRARY_PATH"
$ ./example

You can avoid the use of these environment variables by installing TileDB in a global (standard) location on your system, or hard-coding the path to the TileDB library at build time by configuring the rpath, e.g.

$ g++ -std=c++17 example.cpp -o example \
     -I<path/to/TileDB>/include \
     -L<path/to/TileDB>/lib \
     -Wl,-rpath,<path/to/TileDB>/lib \
     -ltiledb

Building your program this way will result in a binary that will run without having to configure the LD_LIBRARY_PATH or DYLD_LIBRARY_PATH environment variables.

Alternatively, when installing to system-wide paths known to ldconfig (typically in /etc/ld.so.conf.d/* or /etc/ld.so.conf ), run sudo ldconfig after installation to update the search cache.

Last updated