integrating c functions in postgres under windows - Mailing list pgsql-hackers-win32

From Dennis Dauwe
Subject integrating c functions in postgres under windows
Date
Msg-id BAY104-DAV2CF1EE12D7903FB74DF61960D0@phx.gbl
Whole thread Raw
List 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
 
 

 

pgsql-hackers-win32 by date:

Previous
From: "Dave Page"
Date:
Subject: Re: errors in postgresql-8.0.3.zip from 2005-05-12?
Next
From: Jamie Deppeler
Date:
Subject: Optimise PG 8