Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> external procedure and gcc (newbie)
Folks,
Has anyone ever sucessfully compiled an external procedure for Oracle 9i on Solaris using gcc? I attempted to follow the documentation but have not been sucessful. My hunch is that it is the compiler but I'd like to find out for sure if I really need a $3000 compiler to compile a (4 line) stored procedure. My main support for this rather lame conclusion comes from the fact that neither my program nor the demos will compile properly using the demo_rdbms.mk makefile. Please, say it ain't so!
-Matt
If you are interested, here is what I am doing and the errors I am getting. I upgraded gcc from 2.9x to 3.4.3 but have the same errors.
The stored procedure in question compiles when I do this :
gcc execute_cmd.c -o execute_cmd.o
Once compiled "execute_cmd.o xxx" outputs "Your argument was xxx"
If I compile it the way they mention in this tutorial (and the Oracle documentation) :
http://home.clara.net/dwotton/dba/oracle_extn_rtn3.htm
The executable no longer runs from the commandline :
gcc -c execute_cmd.c ./execute_cmd.o chmod 777 ./execute_cmd.o Cannot execute binary file
Here is execute_cmd.c
#include <stdio.h> #include <string.h> int main (int argc, char *argv[]) { if (argc == 2) { printf("Your argument was %s\n", argv[1]); } } void execute_cmd( char* cmd ) { system(cmd); }
Ignoring this bad omen I attempte to keep going. According to the doco, you have to use the demo_rdbms.mk makefile to compile the external procedure. I set LD_LIBRARY_PATH explicitly to avoid "wrong ELF class: ELFCLASS64" errors and then compile.
LD_LIBRARY_PATH=/export/home/oracle/lib32:$LD_LIBRARY_PATH export LD_LIBRARY_PATH gcc -c execute_cmd.c make -f $ORACLE_HOME/rdbms/demo/demo_rdbms.mk extproc_callbackSHARED_LIBNAME=execute_cmdlib.so OBJS=execute_cmd.o
I get this error from the make :
/usr/ccs/bin/ld -G -z text -L/export/home/oracle/product/9.2.0/lib
-R/export/home/oracle/product/9.2.0/lib -o execute_cmdlib.so
execute_cmd.o /export/home/oracle/product/9.2.0/lib/libpls9.a -lclntsh
`cat /export/home/oracle/product/9.2.0/lib/sysliblist`
-R/export/home/oracle/product/9.2.0/lib -laio -lposix4 -lkstat -lm
-lthread
Text relocation remains referenced against symbol offset in file <unknown> 0x28 execute_cmd.o <unknown> 0x2c execute_cmd.o printf 0x34 execute_cmd.o system 0x54 execute_cmd.o ld: fatal: relocations remain against allocatable but non-writable sections *** Error code 1 make: Fatal error: Command failed for target `extproc_callback'
This error goes away if I compile with this commandline :
gcc -c -fPIC execute_cmd.c
If I create the relevant stored procedures grants and stuff in oracle it doesn't (not surprisingly) execute. Instead attempts to use the external procedure like so
DECLARE cmd varchar2(200); BEGIN cmd := '/bin/touch /tmp/yyy'; execute_cmd(cmd); END;
Yeilds oracle erros :
ORA-28595: Extproc agent : Invalid DLL Path ORA-06512: at "SYSTEM.EXECUTE_CMD", line 0 ORA-06512: at line 9Received on Tue Mar 08 2005 - 22:27:56 CST
![]() |
![]() |