Compiling and Installing tmux on SmartOS.

Update: The SmartOS repository starting at 2012Q1 has Tmux1.6 that can be installed by simply running: pkgin in tmux. Here’s a link to the documentation on how to upgrade to 2012Q1.

Since SmartOS was released I’ve been meaning to take it for a spin and see if I like it. Over the weekend I used the Joyent Cloud to spin up a SmartOS64 instance and play with some configuration. The list of packages is OK but not incredible and some of them are pretty outdated. The version of pkgin that comes with SmartOS is missing the provides command which is a real pain in the ass when trying to compile from source.

I, honestly, wouldn’t have ever finished the install without the help of my co-worker Ryan S who, it seems, is really good at tracking down dependencies that are failing and all sorts of other Unix problems.

To install tmux on SmartOS you’ll need to compile some things yourself. You’ll need to compile and manually install:

  • zlib
  • libevent
  • tmux

The versions of zlib and libevent that come with the pkg repo Joyent provides DO NOT work to compile tmux because they’ve been compiled with the wrong ELFCLASS and you’ll just get this error:

ld: fatal: file /opt/local/lib/libz.so: wrong ELF class: ELFCLASS64

There are some packages that you’ll need to install before you can compile and install these modules:

  • python27
  • openssl
  • gcc-compiler
  • gcc-tools
  • gmake
  • gtar
  • gzip
  • libtool-base
  • ncurses

After those are installed you need to install zlib, libevent, and finally tmux:

Installing zlib:

  • wget http://zlib.net/zlib-1.2.6.tar.gz
  • tar xvf zlib-1.2.6.tar.gz
  • cd zlib-1.2.6
  • CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' ./configure --prefix=/opt/local
  • make && make install

Installing libevent:

  • wget https://github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
  • tar xvf libevent-2.0.17
  • cd libevent-2.0.17
  • CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' ./configure --prefix=/opt/local
  • make && make install

Installing tmux:

  • wget http://downloads.sourceforge.net/tmux/tmux-1.6.tar.gz
  • tar xvf tmux-1.6.tar.gz
  • cd tmux-1.6
  • CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib -levent' ./configure --prefix=/opt/local
  • make && make install

You may run into a problem when doing the make step that looks like this:

gcc -DPACKAGE_NAME=\"tmux\" -DPACKAGE_TARNAME=\"tmux\" -DPACKAGE_VERSION=\"1.6\" -DPACKAGE_STRING=\"tmux\ 1.6\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"tmux\" -DVERSION=\"1.6\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CURSES_H=1 -DHAVE_DIRENT_H=1 -DHAVE_FCNTL_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_NCURSES_H=1 -DHAVE_STDINT_H=1 -DHAVE_B64_NTOP=1 -DHAVE_LIBXNET=1 -DHAVE_CLOSEFROM=1 -DHAVE_DAEMON=1 -DHAVE_SETENV=1 -DHAVE_STRLCPY=1 -DHAVE_STRLCAT=1 -DHAVE_ASPRINTF=1 -DHAVE_STRCASESTR=1 -DHAVE_STRSEP=1 -DHAVE_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_DIRFD=1 -DHAVE_SYSCONF=1 -DHAVE___PROGNAME=1 -DHAVE_PROC_PID=1 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -iquote. -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -std=c99 -MT arguments.o -MD -MP -MF .deps/arguments.Tpo -c -o arguments.o arguments.c
In file included from /usr/include/sys/types.h:33:0,
from arguments.c:19:
/opt/local/lib/gcc/i386-pc-solaris2.11/4.6.1/include-fixed/sys/feature_tests.h:362:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
make: *** [arguments.o] Error 1

If you get that error just edit the Makefile and remove the -std=c99 line and run make again.

Now run tmux and you should have a fully functioning tmux installation.