Linking Fails With "Wrong ELF Class: ELFCLASS64" or "Wrong ELF Class: ELFCLASS32" (Doc ID 1525411.1)

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.

Symptoms

An ELFCLASS32 or ELFCLASS64 error message from ld.so.1 is observed.

 ld.so.1: ... fatal: ... wrong ELF class: ELFCLASS32

 OR

 ld.so.1: ... fatal: ... wrong ELF class: ELFCLASS64

 

Example scenarios where such a message can be observed

Example 1:

% setenv LD_PRELOAD /usr/lib/libumem.so
% /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 -m64 -c hello_world.c
% 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.

Example 3:

A 32-bit application is linked against 64-bit Oracle 11g Database client libraries.

ld: fatal: file /oracle/app/oracle/product/11.2.0.3/dbhome_1/lib/libclntsh.so: wrong ELF class: ELFCLASS64
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.

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms