Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

integrating c functions in postgres under windows



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





Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group