Skip to content

2: Dynamic Load

Load C shared objects

Syntax: file symbol 2: (cfn;rnk), 2:[file symbol;(cfn;rnk)]


  • file symbol is a file symbol
  • cfn is the name of a C function (symbol)
  • rnk its rank (int)

returns a function that calls it.

Suppose we have a C function in with the prototype

K q_read_cycles_of_this_cpu(K x);

assign it to read_cycles:

read_cycles:`cpu 2:(`q_read_cycles_of_this_cpu;1)

If the shared library, as passed, does not exist, kdb+ will try to load it from $QHOME/os, where os is the operating system and architecture acronym, e.g. l64, w64, etc.

If using a relative path which does not resolve to reside under $QHOME/os, ensure that LD_LIBRARY_PATH contains the required absolute search path for that library. (On Windows, use PATH instead of LD_LIBRARY_PATH.)

File system
Using C/C++ functions