gap5 libtk8.4.so: wrong ELF class: ELFCLASS32

2011-12-08
2013-04-18
  • On trying to run gap5 from 2.0.0b9.x86_64 on my 64bit Centos 5.6 machine I get the following error:
    couldn't load file "/usr/lib/tk8.4/../libtk8.4.so": /usr/lib/tk8.4/../libtk8.4.so: wrong ELF class: ELFCLASS32

    Any thoughts on how to rectify this? Could this be something to do with it:
    https://www.illumos.org/issues/1066

    Cheers,
    Nathan

     
  • James Bonfield
    James Bonfield
    2011-12-08

    This is almost certainly due to the bizarre way Centos handles its libraries. On a 64-bit OS the libraries in /usr/lib are 32-bit, not 64-bit. Those are hidden away in /usr/lib64 IIRC.

    I thought I handled this, but maybe only when building (I see you have issues there too). Perhaps as a workaround though you could put /usr/lib64 at the front of you LD_LIBRARY_PATH to force the OS to pick 64-bit libraries in preference to 32-bit ones, although I'd have thought it should do that automatically.

     
  • I'm not sure of the correct way to use LD_LIBRARY_PATH but simply putting /usr/lib64 at the front of the LD_LIBRARY_PATH didn't seem to do anything:

    [nwatson-haigh@awrivm1 ~]$ cd ~/staden-2.0.0b9.x86_64/bin
    [nwatson-haigh@awrivm1 bin]$ echo $PATH
    /home/nwatson-haigh/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
    [nwatson-haigh@awrivm1 bin]$ echo $LD_LIBRARY_PATH
    [nwatson-haigh@awrivm1 bin]$ ./gap5
    couldn't load file "/usr/lib/tk8.4/../libtk8.4.so": /usr/lib/tk8.4/../libtk8.4.so: wrong ELF class: ELFCLASS32
    [nwatson-haigh@awrivm1 bin]$ export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
    [nwatson-haigh@awrivm1 bin]$ ./gap5
    couldn't load file "/usr/lib/tk8.4/../libtk8.4.so": /usr/lib/tk8.4/../libtk8.4.so: wrong ELF class: ELFCLASS32
    

    However, if I uninstall 32bit versions of some of the gap5 dependencies I get a different error:

    [nwatson-haigh@awrivm1 bin]$ sudo yum remove curl.i386 tcl.i386 itcl.i386 itk.i386 xz-devel.i386 curl-devel.i386 tk.i386
    [sudo] password for nwatson-haigh: 
    Loaded plugins: fastestmirror
    Setting up Remove Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package curl.i386 0:7.15.5-9.el5_7.4 set to be erased
    ---> Package curl-devel.i386 0:7.15.5-9.el5_7.4 set to be erased
    ---> Package itcl.i386 0:3.3-0.7.RC1.el5 set to be erased
    ---> Package itk.i386 0:3.3-0.4.RC1.el5 set to be erased
    ---> Package tcl.i386 0:8.4.13-4.el5 set to be erased
    ---> Package tk.i386 0:8.4.13-5.el5_1.1 set to be erased
    ---> Package xz-devel.i386 0:4.999.9-0.3.beta.20091007git.el5 set to be erased
    --> Finished Dependency Resolution
    Dependencies Resolved
    ===============================================================================================================================================================================
     Package                               Arch                            Version                                                      Repository                            Size
    ===============================================================================================================================================================================
    Removing:
     curl                                  i386                            7.15.5-9.el5_7.4                                             installed                            463 k
     curl-devel                            i386                            7.15.5-9.el5_7.4                                             installed                            641 k
     itcl                                  i386                            3.3-0.7.RC1.el5                                              installed                            170 k
     itk                                   i386                            3.3-0.4.RC1.el5                                              installed                             96 k
     tcl                                   i386                            8.4.13-4.el5                                                 installed                            2.7 M
     tk                                    i386                            8.4.13-5.el5_1.1                                             installed                            2.3 M
     xz-devel                              i386                            4.999.9-0.3.beta.20091007git.el5                             installed                            145 k
    Transaction Summary
    ===============================================================================================================================================================================
    Remove        7 Package(s)
    Reinstall     0 Package(s)
    Downgrade     0 Package(s)
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Erasing        : itcl                                                                                                                                                    1/7 
      Erasing        : curl-devel                                                                                                                                              2/7 
      Erasing        : itk                                                                                                                                                     3/7 
      Erasing        : tk                                                                                                                                                      4/7 
      Erasing        : xz-devel                                                                                                                                                5/7 
      Erasing        : curl                                                                                                                                                    6/7 
      Erasing        : tcl                                                                                                                                                     7/7 
    Removed:
      curl.i386 0:7.15.5-9.el5_7.4    curl-devel.i386 0:7.15.5-9.el5_7.4                  itcl.i386 0:3.3-0.7.RC1.el5    itk.i386 0:3.3-0.4.RC1.el5    tcl.i386 0:8.4.13-4.el5   
      tk.i386 0:8.4.13-5.el5_1.1      xz-devel.i386 0:4.999.9-0.3.beta.20091007git.el5   
    Complete!
    [nwatson-haigh@awrivm1 bin]$ export LD_LIBRARY_PATH=
    [nwatson-haigh@awrivm1 bin]$ ./gap5
    can't find package Tk
    [nwatson-haigh@awrivm1 bin]$ export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
    [nwatson-haigh@awrivm1 bin]$ ./gap5
    can't find package Tk
    

    I tried to go back and recompile from source. I stared with 32bit and 64bit versions of the dependencies installed and then went from there:

    [nwatson-haigh@awrivm1 staden-2.0.0b9-src]$ sudo yum install xz-devel curl-devel iwidgets itcl itk tcl tk
    [nwatson-haigh@awrivm1 staden-2.0.0b9-src]$ echo $LD_LIBRARY_PATH
    [nwatson-haigh@awrivm1 staden-2.0.0b9-src]$ ./configure CC=gcc44 CXX=g++44 --prefix=$HOME/staden-2.0.0b9 --enable-64bit --with-io_lib=$HOME/io_lib > configure.stdout 2> configure.stderr
    

    From the configure output it seems that a mix of 32bit and 64bit libraries were used (note 32bit versions of Itcl and Itk:

    ----------------------------------------------------------------------
    External packages used:
    curl:      via /usr/bin/curl-config
    zlib:      DIR (system)
    curses:    DIR (system)
    liblzma:   DIR 
    io_lib:    via /home/nwatson-haigh/io_lib/bin/io_lib-config
    Tcl:       via /usr/lib64/tclConfig.sh
    Tk:        via /usr/lib64/tkConfig.sh
    tklib:     /usr/share/tklib0.4
    Iwidgets:  /usr/share/iwidgets4.0.1
    Itcl:      /usr/lib/itcl3.3
    Itk:       /usr/lib/itk3.3
    ----------------------------------------------------------------------
    

    If I uninstall the 32bit versions of the dependencies and try again:

    [nwatson-haigh@awrivm1 staden-2.0.0b9-src]$ sudo yum remove curl.i386 tcl.i386 itcl.i386 itk.i386 xz-devel.i386 curl-devel.i386 tk.i386
    [nwatson-haigh@awrivm1 staden-2.0.0b9-src]$ ./configure CC=gcc44 CXX=g++44 --prefix=$HOME/staden-2.0.0b9 --enable-64bit --with-io_lib=$HOME/io_lib > configure.stdout 2> configure.stderr
    

    The conguration script seems to pick up the 64bit versions of Itcl and Itk as well. This suggests the config script is correctly handling the presence of both 32 and 64 bit versions of Tcl and Tk but not for Itcl and Itk.

    ----------------------------------------------------------------------
    External packages used:
    curl:      via /usr/bin/curl-config
    zlib:      DIR (system)
    curses:    DIR (system)
    liblzma:   DIR 
    io_lib:    via /home/nwatson-haigh/io_lib/bin/io_lib-config
    Tcl:       via /usr/lib64/tclConfig.sh
    Tk:        via /usr/lib64/tkConfig.sh
    tklib:     /usr/share/tklib0.4
    Iwidgets:  /usr/share/iwidgets4.0.1
    Itcl:      /usr/lib64/itcl3.3
    Itk:       /usr/lib64/itk3.3
    ----------------------------------------------------------------------
    

    Another complication is that you get the exact same behaviour when you don't use -enable-64bit. So it would appear that I couldn't compile a 32bit version on my 64bit CentOS.

    Hope this helps in working out some more kinks in the config script! In the mean time, I'll try running gap5 on a Debian/Ubuntu VM.

    Cheers,
    Nathan

     
  • James Bonfield
    James Bonfield
    2011-12-12

    The -enable-64bit is coming from the Tcl configuration, so it seems to be only supported by that sub-package. I'm not sure currently how best to go about fixing that.

    You could try maually pointing configure at the appropriate versions, eg ../configure -with-tcl=/usr/lib64 -with-tk=/usr/lib64 (and similar for itcl, but tbh I wouldn't care about it if you can get away with it as it's not used in any significant way).

    Also note that the recommended configure is to make a subdirectory and use ../configure. Indeed recently I found a bug in using the top-level directory where the tg_index wrapper script gets overwritten by the tg_index binary. That's also something I need to figure out a better solution for - perhaps just by renaming it.