Static compilation does not work in CentOS

Issue #26 new
Former user created an issue

When I try to compile with the following configuration in CentOS 7:

./waf-1.5.18 configure --static Setting blddir to : /dist/qctool1/qctool/build Using prefix : /usr/local Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc Checking for gcc : ok
Checking for library blas : no Checking for library lapack : yes Checking for header sys/time.h : yes Checking for static library z : yes Checking for library dl : yes Checking for library rt : yes Checking for library m : yes Checking for library bz2 : yes Checking for library mgl : not found Checking for library cairo : yes Checking for static library pthread : yes Checking for library readline : yes

I get the following error in the compilation step: ./waf-1.5.18 [...] [727/800] cc_link: build/default/3rd_party/sqlite3/sqlite3/shell_3.o build/default/3rd_party/sqlite3/sqlite3/sqlite3_3.o build/default/3rd_party/sqlite3/extensions/extension-functions_3.o -> build/default/3rd_party/sqlite3-qctool default/3rd_party/sqlite3/sqlite3/sqlite3_3.o: In function unixDlOpen': sqlite3.c:(.text+0x44b9): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(complete.o): In functionrl_username_completion_function': (.text+0x37f9): warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(tilde.o): In function tilde_expand_word': (.text+0x1c4): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking default/3rd_party/sqlite3/sqlite3/shell_3.o: In functionfind_home_dir.part.11': shell.c:(.text+0x1b6e): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(complete.o): In function rl_username_completion_function': (.text+0x37ef): warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(complete.o): In functionrl_username_completion_function': (.text+0x3899): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libpthread.a(libpthread.o): In function sem_open': (.text+0x6823): warning: the use ofmktemp' is dangerous, better use mkstemp' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In functioncr': (.text+0x1eb): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function_rl_move_cursor_relative': (.text+0xd44): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function_rl_move_cursor_relative': (.text+0xd95): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function_rl_move_cursor_relative': (.text+0xe6d): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function_rl_move_vert': (.text+0xf02): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o):(.text+0xf55): more undefined references totputs' follow /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x2764): undefined reference totgoto' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x2776): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x2817): undefined reference totgoto' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x2827): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x287b): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x28c3): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function update_line': (.text+0x2a29): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o): In function rl_redisplay': (.text+0x3f90): undefined reference totputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(display.o):(.text+0x4521): more undefined references to tputs' follow /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_get_screen_size': (.text+0x10c): undefined reference to tgetnum' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_get_screen_size': (.text+0x24b): undefined reference to tgetnum' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x565): undefined reference to PC' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x578): undefined reference to BC' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x583): undefined reference to UP' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x613): undefined reference to tgetent' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x637): undefined reference to tgetstr' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x667): undefined reference to PC' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x67d): undefined reference to BC' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x68b): undefined reference to UP' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x69b): undefined reference to tgetflag' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x6e2): undefined reference to tgetflag' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_init_terminal_io': (.text+0x756): undefined reference to tgetflag' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_backspace': (.text+0x995): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In functionrl_ding': (.text+0xa4f): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_enable_meta_key': (.text+0xab1): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_control_keypad': (.text+0xadb): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o): In function_rl_set_cursor': (.text+0xb1e): undefined reference to tputs' /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libreadline.a(terminal.o):(.text+0xb3c): more undefined references totputs' follow collect2: error: ld returned 1 exit status

I installed readline-static and ncurses-static but that does not solve the issue...

Comments (3)

  1. Jeff Lessem

    Several things need to be done. For this problem, libtinfo must be added when linking with libreadline.

    Once that is solved, you'll find that CentOS/RedHat, don't provide libbz2.a, so this must be created and put someplace that the linker will find it.

    Finally, -lgfortran has to be added when linking qctool_v2.0, because -static-libgcc doesn't seem to know enough to also bring in the fortran library.

    The first issue (tinfo) I solved by editing the wscript in the top level directory and adding

            if conf.check_cxx( lib = 'tinfo', uselib_store = 'TINFO' ):
                    conf.define( 'HAVE_TINFO', 1 )
    

    into the def check_for_3rd_party_components( conf ): block. Then 3rd_party/wscript needs to be edited to add TINFO such:

            bld(
                    features = 'cc cprogram',
                    target = 'sqlite3-qctool',
                    source = [ 'sqlite3/sqlite3/shell.c', 'sqlite3/sqlite3/sqlite3.c
    ', 'sqlite3/extensions/extension-functions.c' ],
                    includes = 'sqlite3/',
                    defines = 'SQLITE_ENABLE_COLUMN_METADATA SQLITE_ENABLE_STAT3 HAV
    E_READLINE',
                    uselib = 'DL READLINE ZLIB M PTHREAD TINFO',
                    cflags = '-O3',
                    export_incdirs = 'sqlite3'
            )
    

    This forum post revealed that libbz2.a is not provided in RedHat based systems, for unknown reasons. It also contains some simple steps to build it yourself. It can then be copied into /usr/lib64

    I haven't yet fixed the wscript to use -lgfortran when linking statically. It's the last thing that happens, so I just ran ./waf-1.5.18 --static -v >& log, and pasted the final link command to the terminal with -lgfortran added at the end.

  2. Jeff Lessem

    Oh yeah, I also had to edit genfile/src/bgen/bgen.cpp and add #include <climits>. I couldn't get RedHat's blas to work, so I used openblas. That required editing components/RelatednessComponent/src/KinshipCoefficientComputer.cpp and changing the blas include to #include "openblas/cblas.h". I also edited the top level wscript so that the blas line is

                    if conf.check_cxx( lib = 'openblas', fragment = '#include "openblas/cblas.h"\nint main() {}', uselib_store = 'CBLAS' ):
    

    I think that was everything I did to get it to build on RedHat.

  3. Log in to comment