Linking Fails With "Wrong ELF Class: ELFCLASS64" or "Wrong ELF Class: ELFCLASS32"
(Doc ID 1525411.1)
Last updated on OCTOBER 08, 2024
Applies to:
Oracle Solaris Studio - Version Forte Developer 6 Update 2 to 12.4 [Release 6.0 to 12]Solaris Operating System - Version 8 6/00 U1 to 11.3 [Release 8.0 to 11.0]
Information in this document applies to any platform.
Symptoms
An ELFCLASS32 or ELFCLASS64 error message from ld.so.1 is observed.
OR
Example scenarios where such a message can be observed
- when using a compiler to compile and link a library or executable
- when directly calling the linker (ld), or ar
- when using tools that process binaries and/or shared libraries, such as ldd
- when trying to start an application
- when trying to load a shared library into an application, for example via dlopen()
- when trying to use a 32-bit plugin in a 64-bit application, and when trying to use a 64-bit plugin in a 32-bit application
Example 1:
% /usr/bin/sparcv9/mdb
ld.so.1: mdb: fatal: /usr/lib/libumem.so: wrong ELF class: ELFCLASS32
Killed
% ldd /usr/bin/sparcv9/mdb
ld.so.1: ldd: fatal: /usr/lib/libumem.so: wrong ELF class: ELFCLASS32
Killed
This example demonstrates a user error - the 64-bit version of mdb is used, but the 32-bit version of libumem is preloaded.
Example 2:
% cc -o <OUTPUT_FILE_NAME> <SOURCE_FILE_NAME>.o
ld: fatal: file <SOURCE_FILE_NAME>.o: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to <OUTPUT_FILE_NAME>
This example also demonstrates a user error: the -m64 option is used inconsistently. First, a 64-bit object file is created. It is then attempted to link this object file into a 32-bit executable.
Example 3:
A 32-bit application is linked against 64-bit Oracle 11g Database client libraries.
ld: fatal: file processing errors. No output written to <OUTPUT_FILE_NAME>
This problem occurs because the Oracle 11g Database by default does not ship 32-bit client libraries.
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Example scenarios where such a message can be observed |
Cause |
Solution |
Steps if the Problem is Observed During Application Startup |
Steps if the Problem Is Observed While Compiling or Linking |
Additional Information for Users of the Template Repository |