I have a function written in C that works well in PostgreSQL under Linux
but I have to move it into PostgreSQL under Windows NT.
I made dll with it by doing followed steps :
1) I added new function at the end of file
int WINAPI mydll_init(HANDLE h, DWORD reason, void *foo)
{
return 1;
}
2) I wrote def file
LIBRARY MYCOMMIT
DESCRIPTION 'MYCOMMIT'
HEAPSIZE 10240
EXPORTS
mycommit @2
3) I made dll using instructions :
gcc -I/usr/src/postgresql-7.0.3/src/include/ -I/usr/src/postgresql-7.0.3/src
/backend/ -shared -c mycommit.c -o mycommit.o
gcc -s -Wl,--base-file,mycommit.base -L/usr/local/pgsql/lib/ -shared -o
mycommit.dll mycommit.o -Wl,-e,_mydll_init@12 -lpostgres
dlltool --base-file mycommit.base --def mycommit.def --output-exp
mycommit.exp --dllname mycommit.dll
gcc -s -Wl,--base-file,mycommit.base,mycommit.exp -L/usr/local/pgsql/lib/ -o
mycommit.dll mycommit.o -Wl,-e,_mydll_init@12 -lpostgres
dlltool --base-file mycommit.base --def mycommit.def --output-exp
mycommit.exp --dllname mycommit.dll
gcc -Wl,mycommit.exp -o mycommit.dll -L/usr/local/pgsql/lib/
mycommit.o -Wl,-e,_mydll_init@12 -lpostgres
dlltool --def mycommit.def --dllname mycommit.dll --output-lib mycommit.a
Next I created function in database with instruction :
CREATE FUNCTION mycommit(text) RETURNS int AS
'/home/administrator/dbfunction/mycommit.a' LANGUAGE 'c';
When I tried to invoke that function followed error eccured :
ERROR: Load of file /home/administrator/dbfunction/mycommit.a failed:
dlopen: Win32 error 193
What is wrong ?
Artur
apl@ite.pl