Installing under Linux
Open a Bash session (eg LXTerminal) in your home folder and
cd to the folder where you downloaded your ZIP file. Unzip the archive. A new folder
q will appear there. Copy it to your home folder and
$ cd ~/Downloads ~/Downloads$ unzip linux-x86.zip Archive: linux-x86.zip inflating: q/README.txt inflating: q/l32/q inflating: q/q.q inflating: q/q.k inflating: q/s.k inflating: q/trade.q inflating: q/sp.q ~/Downloads$ cp -r q ~/. ~/Downloads$ cd $
64-bit or 32-bit?
uname command to determine whether your machine is using the 32-bit or 64-bit Linux distribution.
$ uname -m i686
If the result is
i386 or similar, you are running a 32-bit Linux distribution. If the result is
x86_64, you are running a 64-bit Linux distribution.
If you are installing 32-bit kdb+ on a 32-bit Linux distribution, proceed to Launch (minimum install).
But if you are installing 32-bit kdb+ on a 64-bit Linux distribution, you will need a 32-bit library. Use your usual package manager to install i686 or i386: for example:
sudo apt-get install libc6-i386
AskUbuntu: How to run 32-bit app in Ubuntu 64-bit?
Minimum install and launch
Confirm that kdb+ runs. In your home folder, type
to see the kdb+ banner and the
til 6 to see the first six integers. Type
\\ to return to Linux.
$ q/l32/q KDB+ 3.6 2018.07.30 Copyright (C) 1993-2018 Kx Systems l32/ 2()core 4096MB sjt mark.local 192.168.0.17 NONEXPIRE Welcome to kdb+ 32bit edition For support please see https://groups.google.com/d/forum/personal-kdbplus Tutorials can be found at http://code.kx.com/q/tutorials/install To exit type \\ To remove this startup msg, edit q.q q)til 6 0 1 2 3 4 5 q)\\ $
You have completed the minimum installation. We recommend continuing with Complete install and launch.
Complete install and launch
The minimum installation can be improved in two important ways. We strongly recommend them.
- Call kdb+ within the
rlwrapcommand, which will allow you to call back and edit previous lines
qas a command alias, allowing you to invoke kdb+ without specifying the path to it
Ask for Rlwrap’s version number. If you see one, Rlwrap is already installed
$ 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.
Edit your profile
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.
QHOME with each invocation of the interpreter, as shown below.
QLIC environment variable tells kdb+ where to find a license key file. Absent the variable, the value of
QHOME is used.
In the File Manager, find
.bashrc in your home folder.
Open it with a text editor, append the following line
alias q='QHOME=~/q rlwrap -r ~/q/l32/q'
and save it. Start a new Bash session, or tell Bash to use the revised profile:
$ source .bashrc
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. Exit kdb+.
$ q KDB+ 3.6 2018.07.30 Copyright (C) 1993-2018 Kx Systems l32/ 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/q/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
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 l32/ 4()core 8192MB sjt mint.local 192.168.0.10 EXPIRE 2020.04.01 email@example.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 l64/ 4()core 8192MB sjt mint.local 192.168.0.10 EXPIRE 2020.04.01 firstname.lastname@example.org #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)
sp.q, a sibling of
QHOME, requires the relative path specified.