28 July 2009

Compile LZO, TUN and OpenVPN under Solaris 64bits (revised)

(This post is a revision of this one for Solaris 64bits, and in accordance with new source code versions).


It is possible to get LZO, OpenVPN and TUN under Solaris, compiling the source code.
Because of some compatibility issues, it is not as easy as it can be thought.

You can follow those steps to get openvpn executable under Solaris:
- ensure GNU gcc and make are installed
pkg install SUNWgcc
- download the LZO source code and uncompress it under [LZO_DIRECTORY],
- download the TUN source code and uncompress it under [TUN_DIRECTORY],
- download the openVPN source code and uncompress it under [OPENVPN_DIRECTORY],
- update the path for all needed tools (gcc, gmake, install, ar ...) to be available
export PATH=/usr/sfw/bin:/usr/ucb/:/usr/ccs/bin:/usr/sbin:/usr/bin:$PATH

- compile LZO
cd [LZO_DIRECTORY]
./configure --libdir=/usr/local/lib
make
make install

- configure TUN
cd [TUN_DIRECTORY]
./configure
- edit solaris/Makefile to add options as followed
CFLAGS = -m64 -mcmodel=kernel -mno-red-zone -ffreestanding $(DEFS) -O2 -Wall -D_KERNEL -I.
- compile TUN (ignore the error "Warning: 64-bit version of driver found at /usr/kernel/drv/tun")
make
make install
- move the created tun file (to be regarded as 64bits)
mv /usr/kernel/drv/tun /usr/kernel/drv/amd64/
- load it
devfsadm -i tun

- compile OpenVPN
cd [OPENVPN_DIRECTORY]
./configure --with-lzo-lib=/usr/local/lib --with-lzo-headers=/usr/local/include --prefix=/usr
make
make install


It is now possible to use LZO, OpenVPN and TUN under Solaris.

8 comments:

  1. i tried to compile TUN using the CFLAGS options that you mention for Makefile, but I get an invalid option error.

    bash-3.00$ which make
    /usr/ccs/bin/make
    bash-3.00$ make
    cd solaris; make all
    gcc -m64 -mcmodel=kernel -mno-red-zone -ffreestanding -DTUN_VER=\"1.1\ 08/04/2009\" -O2 -Wall -D_KERNEL -I. -c tun.c
    cc1: error: invalid option `no-red-zone'
    tun.c:1: error: bad value (kernel) for -mcmodel= switch
    *** Error code 1
    make: Fatal error: Command failed for target `tun.o'
    Current working directory /export/home/azrin/Desktop/tun-1.1/solaris
    *** Error code 1
    make: Fatal error: Command failed for target `module'

    ReplyDelete
  2. Are you sure to have installed GNU gcc, and to have updated the PATH environment variable, BEFORE launching ./configure ?

    ReplyDelete
  3. Sorry, I found out what I did wrong.

    The flags you used were for 64 bit x86, but I am on a 64 bit SPARC. So I used:
    CFLAGS = -m64 -mcpu=v9 -mcmodel=medlow -fno-pic -mno-fpu -ffreestanding -nodefaultlibs $(DEFS) -O2 -Wall -D_KERNEL -I.

    This solved all my problems. Great blog post by the way. :)

    ReplyDelete
  4. hello,

    I have:

    bash-3.00# uname -X
    System = SunOS
    Node = develop
    Release = 5.10
    KernelID = Generic_141415-05
    Machine = i86pc
    BusType =
    Serial =
    Users =
    OEM# = 0
    Origin# = 1
    NumCPU = 8

    and did all the steps but i cant attach tun:

    bash-3.00# devfsadm -i tun
    devfsadm: driver failed to attach: tun

    ReplyDelete
  5. Are you sure you moved to the [TUN_DIRECTORY] ? It's mandatory before using devfsadm.



    You can use the -v option to get more information.

    ReplyDelete
  6. I've just tried this on OpenIndiana oi-148. It fails to load the tun driver:


    matt@vault:~/Downloads/tun-1.1$ pfexec devfsadm -v -i tun
    devfsadm: driver failed to attach: tun
    exit status = 1

    The -v option doesn't provide much useful information :(

    ReplyDelete
  7. What is your architecture ?
    Check if the tun driver has well been install either under /usr/kernel/drv/tun or the sub-directory corresponding to your architecture (e.G. /usr/kernel/drv/amd64/).

    ReplyDelete

Thank you for your visit, let's share your point of view: