Errors While running "relink all"

When you want to relink Oracle, you get some errors like Command failed for target `libnmemso'

Error 1:
ld: fatal: library -ljava: not found
ld: fatal: library -ljvm: not found
ld: fatal: File processing errors. No output written to $OH/10.2.0/sysman/lib/libnmemso.so
*** Error code 1
make: Fatal error: Command failed for target `$OH/10.2.0/sysman/lib/libnmemso.so'
Current working directory $OH/10.2.0/sysman/lib
*** Error code 1
make: Fatal error: Command failed for target `libnmemso'


Solution 1
:
As per Metalink note 743833.1, issue was because there are references of source system in make file and fix was to change references from source to target instance. (DB was cloned as part of 11i Cloning steps)

cp $ORACLE_HOME/sysman/lib/env_sysman.mk $ORACLE_HOME/sysman/lib/env_sysman.mk.bak

change
JRE_LIB_DIR=$SOURCE_ORACLE_HOME/10.2.0/jdk/jre/lib/sparc (It was pointing to source Directory)
to
JRE_LIB_DIR=$TARGET_ORACLE_HOME/10.2.0/jdk/jre/lib/sparc

and relink again using "relink all"


Error 2:

ld: warning: file $OH/10.2.0/lib/libclntsh.so.10.1: wrong ELF class: ELFCLASS64
Undefined first referenced symbol in file $OH/10.2.0/lib32//libnmemso.so

ld: fatal: Symbol referencing errors. No output written to $OH/10.2.0/sysman/lib/emagent
*** Error code 1
make: Fatal error: Command failed for target $OH/10.2.0/sysman/lib/emagent
Current working directory $OH/10.2.0/sysman/lib
*** Error code 1
make: Fatal error: Command failed for targetĀ  emagent
ld libclntsh.so.10.1 wrong ELF class ELFCLASS64

Solution 2 : another note from Metalink 395731.1, and fix was to create soft link for file ldflags like

ln -s $ORACLE_HOME/lib/ldflags $ORACLE_HOME/lib32/ldflags

After creating softlink, I did manage to relink all executable in ORACLE_HOME successfully and it was time to run emca for enterprise manager configuration

emca -config dbcontrol db -repos create