Linking Fails With "Wrong ELF Class: ELFCLASS64" or "Wrong ELF Class: ELFCLASS32"
Last updated on MARCH 08, 2017
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.
An ELFCLASS32 or ELFCLASS64 error message from ld.so.1 is observed.
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
ld.so.1: mdb: fatal: /usr/lib/libumem.so: wrong ELF class: ELFCLASS32
% ldd /usr/bin/sparcv9/mdb
ld.so.1: ldd: fatal: /usr/lib/libumem.so: wrong ELF class: ELFCLASS32
This example demonstrates a user error - the 64-bit version of mdb is used, but the 32-bit version of libumem is preloaded.
% cc -o hello_world hello_world.o
ld: fatal: file hello_world.o: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to hello_world
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.
A 32-bit application is linked against 64-bit Oracle 11g Database client libraries.
ld: fatal: file processing errors. No output written to /pssource/ps11gtest/work/myapp
This problem occurs because the Oracle 11g Database by default does not ship 32-bit client libraries.
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
Million Knowledge Articles and hundreds of Community platforms