02 December 2011

Solution of “ORA-06520: PL/SQL: Error loading external library” and “ORA-06522: … :only ET_DYN and ET_EXEC can be loaded”





UNIX
=======
[oracle@dhcppc5 sample_c_ext]$ gcc -c  c_system_lib.c
[oracle@dhcppc5 sample_c_ext]$ ld -r -o  c_system_lib.so c_system_lib.o
[oracle@dhcppc5 sample_c_ext]$ ls -ltr  c_system_lib.so
-rw-rw-r-- 1 oracle oracle 1242 Nov 27 19:08 c_system_lib.so
[oracle@dhcppc5 sample_c_ext]$ chmod 755 c_system_lib.so



ORACLE
=======
SQL> select ExecuteShellCommandViaC('/bin/ls /home/oracle') from dual;
select ExecuteShellCommandViaC('/bin/ls /home/oracle') from dual
                                                            *
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: /home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/c_system_lib.so:
cannot open shared object file: No such file or directory


UNIX
=======
[oracle@dhcppc5 sample_c_ext]$ cp c_system_lib.so $ORACLE_HOME/lib



ORACLE
=======
SQL> select ExecuteShellCommandViaC('/bin/ls /home/oracle') from dual;
select ExecuteShellCommandViaC('/bin/ls /home/oracle') from dual
                                                            *
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: /home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/c_system_lib.so:
only ET_DYN and ET_EXEC can be loaded



UNIX
=======
[oracle@dhcppc5 sample_c_ext]$  gcc -c  c_system_lib.c
[oracle@dhcppc5 sample_c_ext]$ ld -shared -melf_i386 -o c_system_lib.so c_system_lib.o
[oracle@dhcppc5 sample_c_ext]$ chmod 755 c_system_lib.so
[oracle@dhcppc5 sample_c_ext]$ cp c_system_lib.so $ORACLE_HOME/lib
[oracle@dhcppc5 sample_c_ext]$




ORACLE
=======
SQL> select ExecuteShellCommandViaC('/bin/ls /home/oracle') from dual;

EXECUTESHELLCOMMANDVIAC('/BIN/LS/HOME/ORACLE')
--------------------------------------------------------------------------------
apex
apexlistener.sh


No comments: