Successfully installed 32bit qml to run with 32 bit kdb+/q

I recently told someone I had done this and they suggested I post it cause some people seem to be have problems.
So for what it’s worth:
(& by the way, anyone on here in Tokyo)

I successfully build qml (latest version) and have it working with 32-bit kdb+/q
I’m on a 64-bit linux Ubuntu 14.04.2 LTS

Before starting, check if your GNU gcc compiler will successfully compile a c program to 32 bit, because you have to build qml to 32 bit version, as q is 32 bit.
gcc -m32 helloWorld.c -o helloWorld
if this doesn’t work, figure that out somehow.  Google compiling to 32 bit on 64 bit architecture.
 
I pulled in the latest  qml source https://github.com/zholos/qml by Download ZIP on the middle right side.
Unzip it by default to qml-master.

The parameters for the various qml make files are set by running the .configure script file.
And here’s the key, you can pass in parameters to it.  (as documented in top of the configure file.)
./configure KXARCH=l32 FLAGS=-m32 --build-blas --build-lapack |& tee -a ~/logs/qmlconfigure.txt

Note 1
my KXARCH argument to the configure script is “l” because I’m on linux.  If you are not linux, figure out which you should pass.  have a look in configure file.
Note 2
FLAGS=-m32 sets this in various make files to build 32 bit version on QML.   (That’s why I suggested you check if your gcc -m32 works first.)
Note 3
If you ask it to (i.e. using --build-blas --build-lapack) qml will actually pull in and build (a 32 bit version of) blas and lapack and link to them.   And eventually, these are all wrapped up (32-bit qml, blas, lapack) in the final qml.so that gets generated.  So it doesn’t matter if you have 64 bit version of blas and lapack elsewhere on your machine, or 32 bit versions for that matter either.
Note 4
the |& tee … just outputs to a log file, so you can see and keep the results.  Mine are posted below.

If all good, with the configure output, then run
make |& tee -a ~/logs/qmlmake.txt 
I’ve attached my qmlmake.txt log.
(I didn’t run make test or make install.)

If your make has run correctly, you’ll have got to the following which will create qml.so in the ./qml-master/src/ folder:
gcc -m32  -fPIC -pipe -shared -o qml.so const.o alloc.o util.o opt.o libm.o cephes.o lapack.o conmin.o conmax.o nlopt.o \
        -L../lib -lprob -lconmax -lnlopt \
         \
        -llapack \
        -lrefblas \
        -Wl,-Bstatic -lgfortran -Wl,-Bdynamic \
        -lm \
         \
        -Wl,–version-script,qml.mapfile
strip -s qml.so
make[1]: Leaving directory `/home/john/q/qml-master/src’
build complete.

If so, copy the qml.so to your q l32 folder, where q lives.  In my case ~/q/l32/
then copy qml.q (which is also in the ./qml-master/src folder) to your q folder where q.k lives.  Mine is ~/q/

Then load qml in q and a quick touch test by checking for .qml.pi
\l qml.q
.qml.pi

As per above, .configure was run with
./configure KXARCH=l32 FLAGS=-m32 --build-blas --build-lapack |& tee -a ~/logs/qmlconfigure.txt

q operating system… l64 (detected from host)
q version… 3 (default)
q home… /home/john/q (default)
looking for GNU make… make
looking for C compiler… gcc (default)
checking if C compiler compiles… yes
checking if C compiler links… yes
selecting C optimization options… -O2 -fno-strict-aliasing
selecting C floating-point options… -ffloat-store
looking for C compiler for build-time programs… gcc (default)
checking if build-time C compiler compiles… yes
checking if build-time C compiler links… yes
checking if build-time C compiler output runs… yes
looking for Fortran compiler… gfortran (default)
checking if Fortran compiler compiles… yes
checking if Fortran compiler links… yes
selecting Fortran optimization options… -O2
selecting Fortran floating-point options… -ffloat-store
selecting Fortran thread safety options… -frecursive
looking for binutils… ar (default)
selecting target options… -m32
selecting additional compiler options… -pipe
selecting shared library options… -fPIC
selecting how to export specific symbols… -Wl,–version-script
selecting additional libraries for Fortran… -lgfortran
selecting how to link a specific library statically… -Wl,-Bstatic
checking if Fortran locals are placed on stack… yes
will build BLAS
will build LAPACK
checking if patch program works… yes
looking for http downloader… wget
phoning home… just kidding
looking for sha256 program… sha256sum
writing configuration to config.mk
now run make

Firstly, thank you for the very clear build instructions, I have followed them to the letter and the build concludes successfully. 
When I try to load the library at the q console I receive the following error:

KDB+ 3.2 2015.05.27 Copyright (C) 1993-2015 Kx Systems

l32/ 4()core 8115MB i q 127.0.1.1 NONEXPIRE


q)\l qml.q

{x[0] set @[dll 2:;1_x;

{'x}"qml: loading “,string[x 1],”(): ",]}

'qml: loading qml_sin(): /home/i/q/l32/qml.so: undefined symbol: signbitq

q.qml))


Do you know what to make of this? Any guidance would be much appreciated.


I am running 32 bit (i686) debian linux (jessie).

I’ve tried building 32 bit lapack and blas from source and using the --use-blas --use-lapack flags but it looks like my blas build doesn’t work for the qml make (I get an error message when I configure the qml make saying my blas is not working).

I’ve attached both log files to this message. The only difference I’ve noticed between my qmlmake.txt log and yours is that the -m32 flag is called twice on the gfortran command.

Thank you.

I followed all of these steps and ran into the same “undefined symbol signbitq” error. The signbitq function is part of the libquadmath library, so we need to make sure it’s included when it compiles the qml.so. So to do this, before running make look in the config.mk file where you will see a line like:

LIBS_FORTRAN   := -lgfortran

change it to the following:

LIBS_FORTRAN   := -lgfortran -lquadmath

Now run make, when it’s done running it should output:

gcc -m32 -fPIC -pipe -shared -o qml.so const.o alloc.o util.o opt.o libm.o cephes.o lapack.o conmin.o conmax.o nlopt.o \
    -L../lib -lprob -lconmax -lnlopt \
     \
    -llapack \
    -lrefblas \
    -Wl,-Bstatic -lgfortran -lquadmath -Wl,-Bdynamic \
    -lm \
     \
    -Wl,–version-script,qml.mapfile
strip -s qml.so

Notice we can see that -lquadmath has been added.

/mike