My Oracle Support Banner

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.

 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 <SOURCE_FILE_NAME>.c
% 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 <ORACLE_HOME>/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 <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


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.