Getting Lens to run

Jurjen Bokma


Lens is a network simulator. Here's how I compiled it...

  1. sudo mkdir -p /opt/netapps/DouglasRohde/lens1
    pushd /opt/netapps/DouglasRohde/lens
    sudo wget
    sudo tar zxf lens.tar.gz
    sudo rm lens.tar.gz


    Am I really going to compile this thing as root? Yes. Since the running program is going to refer back to the source it was compiled from, and since this directory is going to be on a read-only shared filesystem, I want it to have the ownerships and permissions it was created with. And the machine I'm doing this on will be reinstalled after that action anyway.

  2. In the Makefile, I remove the -march option for the LINUX MACHINE specification. We are building for multiple machines here, and AMD amd64 CPUs may not be happy with Intel core2duo settings. So we go for generic:

    #CFLAGS    = -Wall -O4 -march=i486
    # Above to below JB 20100226
    CFLAGS    = -Wall -O4

  3. If we make all at this point, we'll run into a compiler error that says TCL_TCK is undefined:

    gcc -Wall -O4 -DMACHINE_LINUX -DVERSION=\"2.63\" \
    -DTCLVER=\"8.3.4\" -I../TclTk/tcl8.3.4/generic -I../TclTk/tk8.3.4/generic -DADVANCED -c -o ../Obj//command.o \
    command.c: In function Ã_niceÃ
    command.c:111: warning: ignoring return value of Ãiceàdeclared with attribute warn_unused_result
    command.c: In function Ã_timeÃ
    command.c:151: error: ÃLK_TCKÃundeclared (first use in this function)
    command.c:151: error: (Each undeclared identifier is reported only once
    command.c:151: error: for each function it appears in.)
    make[1]: *** [../Obj//command.o] Error 1

    I suspect that the source is not maintained very actively, and this bugreport holds the solution. So I replace CLK_TCK with CLOCKS_PER_SECOND as is suggested there:

    grep -ri CLK_TCK ./*
    ./Src/command.c:                (real) (userticks + systicks) / CLK_TCK,
    ./Src/command.c:                (real) userticks / CLK_TCK,
    ./Src/command.c:                (real) systicks / CLK_TCK,
    ./Src/command.c:                (real) realticks / CLK_TCK);
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h: * gettimeofday call, then must use times and the CLK_TCK #define (from
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h: * have HZ and no CLK_TCK, and some might not even have HZ.
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#   ifndef CLK_TCK
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#           define CLK_TCK HZ
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#           define CLK_TCK 60
    grep -ri CLOCKS_PER_SEC ./*
    sed -i 's%CLK_TCK%CLOCKS_PER_SEC%g' ./Src/command.c ./TclTk/tcl8.3.4/unix/tclUnixPort.h
    grep -ri CLOCKS_PER_SEC ./*
    ./Src/command.c:                (real) (userticks + systicks) / CLOCKS_PER_SEC,
    ./Src/command.c:                (real) userticks / CLOCKS_PER_SEC,
    ./Src/command.c:                (real) systicks / CLOCKS_PER_SEC,
    ./Src/command.c:                (real) realticks / CLOCKS_PER_SEC);
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h: * gettimeofday call, then must use times and the CLOCKS_PER_SEC #define (from
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h: * have HZ and no CLOCKS_PER_SEC, and some might not even have HZ.
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#   ifndef CLOCKS_PER_SEC
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#           define CLOCKS_PER_SEC HZ
    ./TclTk/tcl8.3.4/unix/tclUnixPort.h:#           define CLOCKS_PER_SEC 60

  4. I needed to add a few packages. I didn't investigate which ones I also neede, but already had. The necessary packages are now in my standard LWP.

    apt-get install -y tk8.3 tk8.3-dev

  5. As the manual says:

    sudo make all
    ln -s -f /opt/netapps/DouglasRohde/lens/Bin//lens-2.63 /opt/netapps/DouglasRohde/lens/Bin//lens
    ln -s -f /opt/netapps/DouglasRohde/lens/Bin//lens-2.63 ../lens
    make[1]: Leaving directory `/opt/netapps/DouglasRohde/lens/Src'

  6. We write a little wrapper script for that in /opt/netapps/bin/lens, according to the manual:

    export LENSDIR=/opt/netapps/DouglasRohde/lens
    export PATH=${PATH}:${LENSDIR}/Bin/${HOSTTYPE}
    exec ${LENSDIR}/Bin/lens