integrating c functions in postgres under windows

From: "Dennis Dauwe" <d_dauwe(at)hotmail(dot)com>
To: <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: integrating c functions in postgres under windows
Date: 2005-05-24 16:07:33
Message-ID: BAY104-DAV2CF1EE12D7903FB74DF61960D0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32

I try to integrate some c functions in postgres running under windows.

Compiling this function into a .dll file and try to create a function with:

CREATE FUNCTION eins_addieren(integer) RETURNS integer
AS '$libdir/function', 'eins_addieren'
LANGUAGE C STRICT;

alway gives this error massage:

ERROR: could not load library "C:/PostgreSQL/8.0/lib/dlltest4.dll": dynamic load error

I am using the following code for the dll file:

/* file: dll.h */
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

DLLIMPORT int eins_addieren (int);

#endif /* _DLL_H_ */

/* file : dllmain.c */

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include "postgres.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

DLLIMPORT int eins_addieren (int arg)
{
return arg+1;
}

BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;

case DLL_PROCESS_DETACH:
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
break;
}

/* Returns TRUE on success, FALSE on failure */
return TRUE;
}

what's wrong with this code ??
my compiler is Dev-C++ 4.9.9.2

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Jamie Deppeler 2005-06-01 04:21:34 Optimise PG 8
Previous Message Dave Page 2005-05-13 07:50:01 Re: errors in postgresql-8.0.3.zip from 2005-05-12?