FWIW, I encountered similar looking errors while trying to configure and build a statically linked gvim binary . The complete information (including configure logs etc.,) can be found at https://groups.google.com/forum/#!topic/vim_use/rQBp0rsJ98U .
To summarize, consider the following rajulocal@hogwarts:~/compile_static_gvim_native/problems$ cat conftest.c /* confdefs.h */ #define PACKAGE_NAME "" #define PACKAGE_TARNAME "" #define PACKAGE_VERSION "" #define PACKAGE_STRING "" #define PACKAGE_BUGREPORT "" #define PACKAGE_URL "" #define UNIX 1 #define STDC_HEADERS 1 #define HAVE_SYS_WAIT_H 1 #define HAVE_SELINUX 1 #define FEAT_HUGE 1 #define USE_XSMP_INTERACT 1 #define HAVE_LIBNSL 1 #define FEAT_NETBEANS_INTG 1 /* end confdefs.h. */ #include <X11/Xlib.h> int main () { XrmInitialize () ; return 0; } This program compiles without the "-static" option. But gives errors otherwise. The following command works. But the one after does not. rajulocal@hogwarts:~/compile_static_gvim_native/problems$ gcc -o conftest -g -O2 -I/usr/local/include -L/usr/local/lib file1.c -lX11 -lnsl -lselinux rajulocal@hogwarts:~/compile_static_gvim_native/problems$ gcc -o conftest -g -O2 -I/usr/local/include -static -L/usr/local/lib file1.c -lX11 -lnsl -lselinux /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xim_trans.o): In function `_XimXTransSocketUNIXConnect': (.text+0xe12): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `require_socket': (.text+0x652): undefined reference to `xcb_take_socket' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `poll_for_event': (.text+0x7d4): undefined reference to `xcb_poll_for_event' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `poll_for_response': (.text+0x8c2): undefined reference to `xcb_poll_for_reply' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XSend': (.text+0xada): undefined reference to `xcb_writev' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XReadEvents': (.text+0xc38): undefined reference to `xcb_connection_has_error' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XReadEvents': (.text+0xcd4): undefined reference to `xcb_wait_for_event' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XEventsQueued': (.text+0xdfd): undefined reference to `xcb_connection_has_error' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XAllocIDs': (.text+0xedb): undefined reference to `xcb_generate_id' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): In function `_XReply': (.text+0x1045): undefined reference to `xcb_wait_for_reply' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(ClDisplay.o): In function `XCloseDisplay': (.text+0xd3): undefined reference to `xcb_disconnect' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(OpenDis.o): In function `OutOfMemory': (.text+0x4d4): undefined reference to `xcb_disconnect' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(OpenDis.o): In function `XOpenDisplay': (.text+0x8fd): undefined reference to `xcb_get_setup' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(OpenDis.o): In function `XOpenDisplay': (.text+0xb41): undefined reference to `xcb_get_maximum_request_length' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x1ac): undefined reference to `xcb_parse_display' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x206): undefined reference to `xcb_connect_to_display_with_auth_info' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x226): undefined reference to `xcb_get_file_descriptor' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x243): undefined reference to `xcb_generate_id' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x29c): undefined reference to `pthread_cond_init' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x2ae): undefined reference to `pthread_cond_init' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x2b6): undefined reference to `xcb_connection_has_error' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB': (.text+0x2d6): undefined reference to `xcb_connect' collect2: error: ld returned 1 exit status rajulocal@hogwarts:~/compile_static_gvim_native/problems$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-5) rajulocal@hogwarts:~/compile_static_gvim_native/problems$ dpkg -l libc6 ii libc6:amd64 2.13-38 amd64 Embedded GNU C Library: Shared libraries ii libc6:i386 2.13-38 i386 Embedded GNU C Library: Shared libraries rajulocal@hogwarts:~/compile_static_gvim_native/problems$ uname -a Linux hogwarts 3.2.0-4-amd64 #1 SMP Debian 3.2.39-2 x86_64 GNU/Linux -- Kamaraju S. Kusumanchi http://malayamaarutham.blogspot.com/