64 bit compatability
Hi everyone,
1.
I'm using studio 11 CC on Solaris 10 and tyring to link with a vendor's 64 bit library. I'm getting
wrong ELF class: ELFCLASS64
On the vendor's library. From the CC man page I figure that
a. The first object given to ld is 32 bit
b. The vendor's library is 64 bit
c. They cannot mix.
Am I right so far?
How do I compile my program for 64 bit such that it will be compatible with the library?
2.
The vendor also provides example programs using his library. The provided makefile is trying to use -xtarget=opteron -xarch=amd64 and they are rejected by the compiler
CC: illegal option usage -xarch=amd64
Are these 2 options strictly for x86 or amd processors? is the vendor wrong to include them in a download named x64_solaris_10_11?
I have removed these options from the make and now I'm getting the same error from ld about the library:
wrong ELF class: ELFCLASS64
[989 byte] By [
ran.hilai] at [2007-11-26 9:11:23]

# 1
Sorry, linking 32-bit object files/libraries with 64-bit object files/libraries is not allowed. "Wrong ELF class" error message is an indication that you are attempting to do so. Before linking, please check the bitness of the objects you are trying to link. To compile for 64-bit successfully, all the object files should be produced using -xarch=amd64 option.
As for the second error, could you please show the complete compilation line?
Thanks,
Boris
# 2
Thanks, Boris.
Based on your input, the second error is really the same as the first.
My problem is that CC is rejecting -xarch=amd64
[freestar] 4:16pm ~/tests >CC -xarch=amd64 t.cpp -o t
CC: illegal option usage -xarch=amd64
[freestar] 4:16pm ~/tests >version `which CC`
version of "/opt/SUNWspro/bin/CC": Sun C++ 5.8 2005/10/13
[freestar] 4:17pm ~/tests >uname -a
SunOS freestar 5.10 Generic_118822-23 sun4u sparc SUNW,Sun-Fire-V210
[freestar] 4:17pm ~/tests >
# 3
The -xarch=amd64 and -xtarget=opteron options can be used only on an x64 system like an opteron.
On a SPARC system, the the 64-bit option is -xarch=v9.
The option -xarch=generic64 works for both SPARC and x64.
Refer to the C++ Compiler Options in the appendix of the C++ Users Guide for more details.
As always, you cannot mix 32-bit binaries and 64-bit binaries in the same program.