Andre Lue wrote:
getting  "ld: fatal: file smartd.o: wrong ELF class: ELFCLASS64" when trying to 
build 64 bit versions of programs for most things where the 32 bit version  builds fine.

gmake  all-recursive
gmake[1]: Entering directory `/home/andre.l/smart/smartmontools-5.38'
Making all in .
gmake[2]: Entering directory `/home/andre.l/smart/smartmontools-5.38'
source='utility.cpp' object='utility.o' libtool=no \
        DEPDIR=.deps depmode=none /usr/bin/bash ./depcomp \
        CC -DHAVE_CONFIG_H -I.  -DSMARTMONTOOLS_SYSCONFDIR=\"/usr/local/etc\" 
-m64   -erroff=%none,wbadinitl,wbadasgl,badargtypel2w -xO2  -library=no%Cstd,no%Crun  -c 
-o utility.o utility.cpp
source='os_solaris.cpp' object='os_solaris.o' libtool=no \
        DEPDIR=.deps depmode=none /usr/bin/bash ./depcomp \
        CC -DHAVE_CONFIG_H -I.  -DSMARTMONTOOLS_SYSCONFDIR=\"/usr/local/etc\" 
-m64   -erroff=%none,wbadinitl,wbadasgl,badargtypel2w -xO2  -library=no%Cstd,no%Crun  -c 
-o os_solaris.o os_solaris.cpp
CC -erroff=%none,wbadinitl,wbadasgl,badargtypel2w -xO2 -library=no%Cstd,no%Crun -library=no%Cstd,no%Crun -o smartd smartd.o atacmdnames.o atacmds.o ataprint.o knowndrives.o scsicmds.o scsiata.o scsiprint.o utility.o os_solaris.o -lnsl ld: fatal: file smartd.o: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to smartd
gmake[2]: *** [smartd] Error 1
gmake[2]: Leaving directory `/home/andre.l/smart/smartmontools-5.38'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/andre.l/smart/smartmontools-5.38'
gmake: *** [all] Error 2

for d in `ls *.o`; do file $d; done
atacmdnames.o:  ELF 64-bit LSB relocatable AMD64 Version 1
atacmds.o:      ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
ataprint.o:     ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
knowndrives.o:  ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
os_solaris.o:   ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
scsiata.o:      ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
scsicmds.o:     ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]
scsiprint.o:    ELF 64-bit LSB relocatable AMD64 Version 1 [SSE2 CMOV]
smartd.o:       ELF 64-bit LSB relocatable AMD64 Version 1 [SSE CMOV]
utility.o:      ELF 64-bit LSB relocatable AMD64 Version 1 [CMOV]

if I recompose the failure line and add -m64 it completes. Am I doing something 
wrong or is there something wrong with the code? Can someone guide me on a 
proper fix for this?

CC  -erroff=%none,wbadinitl,wbadasgl,badargtypel2w -m64 -xO2  
-library=no%Cstd,no%Crun   -library=no%Cstd,no%Crun  -o smartd smartd.o 
atacmdnames.o atacmds.o ataprint.o knowndrives.o scsicmds.o scsiata.o 
scsiprint.o utility.o  os_solaris.o  -lnsl

This is the env used:
export CC=/opt/SUNWspro/bin/cc
export CCX=/opt/SUNWspro/bin/CC
export CONFIG_SHELL=/usr/bin/bash
export PATH=/opt/SUNWspro/bin:/usr/bin:/usr/sbin:/usr/ccs/bin:/usr/ucb
ulimit -s 32768
export CXXFLAGS=" -library=no%Cstd,no%Crun "
export LDFLAGS=" -library=no%Cstd,no%Crun "
export CFLAGS=" -m64 "
export CPPFLAGS=" -m64 "


Just a guess, but I bet that if you add a '-dryrun' option to
your CC line, you'll see that the compiler is adding one or
more 32-bit objects at the head of the command line that it
feeds to the linker.

The linker decides what type of object it's building based on the
first object on the command line, so if I'm right about the above,
then that 32-bit object is going to cause ld to complain when it
encounters your 64-bit objects.

The right fix is to tell the compiler to produce a 64-bit object
with -m64 as you've done.

- Ali

_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to