Installing under macOS

After downloading, if necessary, unzip the archive. A new folder q will appear in your Downloads folder.

Next perform the Minimum install and launch. We then strongly recommend continuing to Complete install and launch.

macOS Catalina (10.15) ended macOS support for 32-bit applications.

Minimum install and launch

Open the Terminal application and enter the following commands:

$ cd ~/Downloads
~/Downloads$ cp -r q ~/.
~/Downloads$ cd ~
$ q/m32/q
KDB+ 3.6 2018.07.30 Copyright (C) 1993-2018 Kx Systems
m32/ 2()core 4096MB sjt mark.local 192.168.0.17 NONEXPIRE

Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/v2/tutorials/install
To exit type \\
To remove this startup msg, edit q.q
q)til 6 / first 6 integers
0 1 2 3 4 5
q)\\
$

You have installed and launched kdb+.

To exit from kdb+, type \\

Complete install and launch

The minimum installation can be improved in two important ways. We strongly recommend them.

  • Call kdb+ within the rlwrap command, which will allow you to call back and edit previous lines
  • Define q as a command alias, allowing you to invoke kdb+ without specifying the path to it

Install Rlwrap

Exit kdb+ to return to the command prompt and your home folder. Ask for Rlwrap’s version number. If you see one, Rlwrap is already installed.

q)\\
$ rlwrap -v
rlwrap 0.42
$

If Rlwrap is already installed you can go on to the next step.

Otherwise, you will be told rlwrap: command not found. Install Rlwrap using your package manager. (Probably either MacPorts or Homebrew)

Edit your profile

Environment variables

The q interpreter refers to environment variable QHOME for the location of certain files. Absent this variable, it will guess based on the path to the interpreter. Better to set the variable explicitly.

If you run just one version of kdb+, it might suit you to define QHOME in your Bash profile and export it for use by non-console processes.

Otherwise set QHOME with each invocation of the interpreter, as shown below.

The QLIC environment variable tells kdb+ where to find a license key file. Absent the variable, the value of QHOME is used.

In Terminal (Bash), open your profile ~/.bashrc with TextEdit, Sublime Text or your favourite text editor,

$ open -a "Sublime Text" .bashrc

append the following line

alias q='QHOME=~/q rlwrap -r ~/q/m32/q'

and save it. Start a new Terminal session, or tell Bash to use the revised profile:

$ source .bashrc

Installing elsewhere

You can install kdb+ where you please. The environment variables QHOME (specified above) and QLIC tell kdb+ where to find its files.

Confirm successful installation

From your home folder, launch kdb+, type an expression and recall it using the up-arrow key:

$ q
KDB+ 3.6 2018.07.30 Copyright (C) 1993-2018 Kx Systems
m32/ 2()core 4096MB sjt mark.local 192.168.0.17 NONEXPIRE

Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/v2/tutorials/install
To exit type \\
To remove this startup msg, edit q.q
q)til 6 / first 6 integers
0 1 2 3 4 5
q)til 6 / first 6 integers
0 1 2 3 4 5
q)\\
$

Install a license key file

64-bit kdb+ requires a license key file. Obtain and install one.

You’re done. You have completely installed kdb+.

Installing multiple versions

For any version of q, 64-bit and 32-bit interpreter binaries share the same q.k file, located in QHOME for that version.

All versions share the same k4.lic license-key file.

Arrange your files as in this example:

$ tree q
q
├── k4.lic
├── phrases.q
├── sp.q
├── trade.q
├── v3.5
│   ├── m32
│   │   └── q
│   ├── m64
│   │   └── q
│   └── q.k
└── v3.6
    ├── m64
    │   └── q
    └── q.k

In .bash_profile export QLIC and define aliases as in this example:

# versions of q
export QLIC=~/q
alias    q='export QHOME=~/q/v3.6; rlwrap -r $QHOME/m64/q'
alias q3.5='export QHOME=~/q/v3.5; rlwrap -r $QHOME/m64/q'
alias  q32='export QHOME=~/q/v3.5; rlwrap -r $QHOME/m32/q'

In a command shell:

$ q32
KDB+ 3.5 2019.05.15 Copyright (C) 1993-2019 Kx Systems
m32/ 4()core 8192MB sjt mint.local 192.168.0.10 EXPIRE 2020.04.01 stephen@kx.com #55032

q)\\
$

The 32-bit interpreter finds and reports the license-key file even though it will run without it.

$ q
KDB+ 3.6 2019.03.07 Copyright (C) 1993-2019 Kx Systems
m64/ 4()core 8192MB sjt mint.local 192.168.0.10 EXPIRE 2020.04.01 stephen@kx.com #55032

q)\pwd
"/Users/sjt"
q)\echo $QLIC
"/Users/sjt/q"
q)\echo $QHOME
"/Users/sjt/q/v3.6"
q)\l ../sp.q
+`p`city!(`p$`p1`p2`p3`p4`p5`p6`p1`p2;`london`london`london`london`london`lon..
(`s#+(,`color)!,`s#`blue`green`red)!+(,`qty)!,900 1000 1200
+`s`p`qty!(`s$`s1`s1`s1`s2`s3`s4;`p$`p1`p4`p6`p2`p2`p4;300 200 100 400 200 300)
q)

Loading sp.q, a sibling of QHOME, requires the relative path specified.

What’s next?

Learn the q programming language, look through the reference card, or see in the Knowledge Base what you can do with kdb+.