Ask sendai

UNIX is Art

Compile tmux on Solaris 10 / Solaris 11

Posted By on December 24, 2012 in Solaris 10, Solaris 11 | 3 comments

If you ever tried to compile tmux 1.7 on Solaris 10 or Solaris 11 and it failed, probably this post will help you to get through. If you don’t know tmux, it’s a screen-like tool but more advanced in many ways.

The ‘configure’ script should run without a problem, hopefully you installed libevent¬†already as it’s a requirement for tmux. If you forgot to install libevent, the configure script will bail out anyway. Here is a successful ‘configure’ :

wind-vm-solaris10% ./configure
checking for a BSD-compatible install... etc/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... etc/install-sh -c -d
checking for gawk... no
checking for mawk... no
...
checking for /proc/$$... yes
checking platform... sunos
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands

next, we can start compiling with ‘gmake’ :

wind-vm-solaris10% gmake
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include    -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -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:17,
                 from arguments.c:19:
/usr/include/sys/feature_tests.h:337:2: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications         and pre-2001 POSIX applications"
gmake: *** [arguments.o] Error 1

first surprise, we have to re-run ‘configure’ with CPPFLAGS and LDFLAGS set enforcing XPG6 standards :

wind-vm-solaris10% CPPFLAGS="-D_XPG6" LDFLAGS="-D_XPG6" ./configure
checking for a BSD-compatible install... etc/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... etc/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking build system type... i386-pc-solaris2.10
...
checking for /proc/$$... yes
checking platform... sunos
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands

now, gmake will go further :

wind-vm-solaris10% gmake
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include   -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -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
mv -f .deps/arguments.Tpo .deps/arguments.Po
...
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include   -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS   -std=c99    -MT client.o -MD -MP -MF .deps/client.Tpo -c -o client.o client.c
client.c: In function `client_get_lock':
client.c:81: warning: implicit declaration of function `flock'
client.c:81: error: `LOCK_EX' undeclared (first use in this function)
client.c:81: error: (Each undeclared identifier is reported only once
client.c:81: error: for each function it appears in.)
client.c:81: error: `LOCK_NB' undeclared (first use in this function)
client.c: In function `client_main':
client.c:246: warning: implicit declaration of function `cfmakeraw'
gmake: *** [client.o] Error 1

Compiling fails because Solaris 10 and Solaris 11 core libraries does not include functions for flock() or cfmakeraw(). In order to work around this, you should download and apply this patch. Now, I have to warn you this is not my patch, neither it’s official, but it works. The patch was submitted by nxmehta, and hopefully it will get tested and merged into the next tmux release. So, let’s continue. You can download the patch, apply it to client.c, and the build will complete. First, download the patch and apply it :

wind-vm-solaris10% wget http://simplex.swordsaint.net/files/2012_12_24/tmux_1_7_solaris.patch
--2012-12-24 10:39:54--  http://simplex.swordsaint.net/files/2012_12_24/tmux_1_7_solaris.patch
Resolving simplex.swordsaint.net... 195.56.77.27
Connecting to simplex.swordsaint.net|195.56.77.27|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1152 (1.1K) [text language="/plain"][/text]
Saving to: `tmux_1_7_solaris.patch'

100%[==================================================================================================================>] 1,152       --.-K/s   in 0.001s  

2012-12-24 10:39:54 (767 KB/s) - `tmux_1_7_solaris.patch' saved [1152/1152]

wind-vm-solaris10% patch <tmux_1_7_solaris.patch
  Looks like a unified context diff.
File to patch: client.c
done
wind-vm-solaris10% grep -i solaris client.c
/* BEGIN SOLARIS 11 FIX */
/* END SOLARIS 11 FIX */

these two lines tell you that the patching was successful, so the build should continue like a charm :

wind-vm-solaris10% gmake
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include   -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS   -std=c99    -MT client.o -MD -MP -MF .deps/client.Tpo -c -o client.o client.c
mv -f .deps/client.Tpo .deps/client.Po
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include   -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS   -std=c99    -MT clock.o -MD -MP -MF .deps/clock.Tpo -c -o clock.o clock.c
mv -f .deps/clock.Tpo .deps/clock.Po
...
gcc -DPACKAGE_NAME="tmux" -DPACKAGE_TARNAME="tmux" -DPACKAGE_VERSION="1.7" -DPACKAGE_STRING="tmux 1.7" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="tmux" -DVERSION="1.7" -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_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_DECL_OPTARG=0 -DHAVE_DECL_OPTIND=0 -DHAVE_DECL_OPTRESET=0 -DHAVE_BZERO=1 -DHAVE_SYSCONF=1 -DHAVE_PROC_PID=1 -I.   -I/usr/local/include   -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED   -I. -I- -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS   -std=c99    -MT strtonum.o -MD -MP -MF .deps/strtonum.Tpo -c -o strtonum.o `test -f 'compat/strtonum.c' || echo './'`compat/strtonum.c
mv -f .deps/strtonum.Tpo .deps/strtonum.Po
gcc   -std=c99     -D_XPG6 -o tmux arguments.o attributes.o cfg.o client.o clock.o cmd-attach-session.o cmd-bind-key.o cmd-break-pane.o cmd-capture-pane.o cmd-choose-buffer.o cmd-choose-client.o cmd-choose-list.o cmd-choose-tree.o cmd-clear-history.o cmd-clock-mode.o cmd-command-prompt.o cmd-confirm-before.o cmd-copy-mode.o cmd-delete-buffer.o cmd-detach-client.o cmd-display-message.o cmd-display-panes.o cmd-find-window.o cmd-has-session.o cmd-if-shell.o cmd-join-pane.o cmd-kill-pane.o cmd-kill-server.o cmd-kill-session.o cmd-kill-window.o cmd-link-window.o cmd-list-buffers.o cmd-list-clients.o cmd-list-commands.o cmd-list-keys.o cmd-list-panes.o cmd-list-sessions.o cmd-list-windows.o cmd-list.o cmd-load-buffer.o cmd-lock-server.o cmd-move-window.o cmd-new-session.o cmd-new-window.o cmd-paste-buffer.o cmd-pipe-pane.o cmd-refresh-client.o cmd-rename-session.o cmd-rename-window.o cmd-resize-pane.o cmd-respawn-pane.o cmd-respawn-window.o cmd-rotate-window.o cmd-run-shell.o cmd-save-buffer.o cmd-select-layout.o cmd-select-pane.o cmd-select-window.o cmd-send-keys.o cmd-send-prefix.o cmd-server-info.o cmd-set-buffer.o cmd-set-environment.o cmd-set-option.o cmd-show-buffer.o cmd-show-environment.o cmd-show-messages.o cmd-show-options.o cmd-source-file.o cmd-split-window.o cmd-start-server.o cmd-string.o cmd-suspend-client.o cmd-swap-pane.o cmd-swap-window.o cmd-switch-client.o cmd-unbind-key.o cmd-unlink-window.o cmd.o colour.o control.o control-notify.o environ.o format.o grid-utf8.o grid-view.o grid.o input-keys.o input.o job.o key-bindings.o key-string.o layout-custom.o layout-set.o layout.o log.o mode-key.o names.o notify.o options-table.o options.o paste.o resize.o screen-redraw.o screen-write.o screen.o server-client.o server-fn.o server-window.o server.o session.o signal.o status.o tmux.o tty-acs.o tty-keys.o tty-term.o tty.o utf8.o window-choose.o window-clock.o window-copy.o window.o xmalloc.o xterm-keys.o osdep-sunos.o forkpty-sunos.o imsg.o imsg-buffer.o       fgetln.o getopt.o strcasestr.o strsep.o vis.o unvis.o strtonum.o   -lxnet -lsocket -lnsl -lcurses -L/usr/local/lib -levent   -lrt  -lresolv

and the result :

wind-vm-solaris10% ./tmux -V
tmux 1.7

Tested on Solaris 11.0 and Solaris 10u10 (147441-01).

And in short what we did :

  1. download tmux 1.7
  2. download patch
  3. apply patch
  4. configure tmux with ‘CPPFLAGS=”-D_XPG6″ LDFLAGS=”-D_XPG6″ ./configure’
  5. gmake

sendai

3 Comments

  1. Ashish February 8, 2013

    Thanks!, this helped me compile tmux on Solaris 10.

  2. Swaroop M S April 5, 2013

    Hi,

    The patch worked like a charm for me on Solaris 11. Thanks!

    Now there’s a problem with the newly released tmux 1.8 on Solaris. I did a “make” and after a while I run into some new errors. Could you please guide me on how to get this error solved?

    gcc -DPACKAGE_NAME=”tmux” -DPACKAGE_TARNAME=”tmux” -DPACKAGE_VERSION=”1.8″ -DPACKAGE_STRING=”tmux 1.8″ -DPACKAGE_BUGREPORT=”” -DPACKAGE_URL=”” -DPACKAGE=”tmux” -DVERSION=”1.8″ -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_PATHS_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TREE_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/libevent-2.0.21-stable/include -D_XPG6 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -iquote. -I/usr/local/include -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -std=gnu99 -O2 -MT server-client.o -MD -MP -MF .deps/server-client.Tpo -c -o server-client.o server-client.c
    server-client.c: In function ‘server_client_check_resize’:
    server-client.c:544:7: error: ‘errno’ undeclared (first use in this function)
    server-client.c:544:7: note: each undeclared identifier is reported only once for each function it appears in
    server-client.c:544:16: error: ‘EINVAL’ undeclared (first use in this function)
    *** Error code 1
    make: Fatal error: Command failed for target `server-client.o’

    Thanks,
    Swaroop

  3. Swaroop M S April 5, 2013

    Ok, I got this working myself. It was just a very minor fix as one of the header files was missing in the file.

    Thanks,
    Swaroop

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>