Обсуждение: using dll in am

Поиск
Список
Период
Сортировка

using dll in am

От
David Hoksza
Дата:
Hi, I'm trying to implement my own access method, which uses c++
framework for saving tuples. The framework consists of set of
functions, which are implemented in win32 dll.
All the functions which are desired by PG (ambuild, aminsert, ...) are
implemented and functional. But when I want to use any of the
functions from dll so there's problem when loading the dll in
dynloader. It says that function can't be found (in the time of
loading the dll).
I do following steps:

1. Compiling the dll in Microsoft Visual Studio.
2. Creating the def file (in mingw32):
  impdef rtreewrapper.def rtreewrapper.dll
  which yealds in the folowing def file:

LIBRARY     RTREEWRAPPER.DLL

EXPORTS   f_cRTreeItem_GetSize          = _f_cRTreeItem_GetSize@4                f_cRTreeLeafItem_GetSize      =
_f_cRTreeLeafItem_GetSize@4           f_cRTreeLeafItem_size         = _f_cRTreeLeafItem_size@0               f_header
                  = _f_header@0                            f_header_ComputeNodeSize      = _f_header_ComputeNodeSize@4
         f_header_CreateSpaceDescriptor= _f_header_CreateSpaceDescriptor@12
f_header_GetSpaceDescriptor_GetDimension=_f_header_GetSpaceDescriptor_GetDimension@4
f_header_GetSpaceDescriptor_SetBitSize=_f_header_GetSpaceDescriptor_SetBitSize@12         f_header_SetLeafNodeItemSize
=_f_header_SetLeafNodeItemSize@8         f_header_SetNodeItemSize      = _f_header_SetNodeItemSize@8
f_leafitem1                  = _f_leafitem1@0                         f_leafitem                    = _f_leafitem@4
                    f_leafitem_GetTuple_GetValue_GenerateRandom= _f_leafitem_GetTuple_GetValue_GenerateRandom@8
f_leafitem_Resize            = _f_leafitem_Resize@8                   f_timer                       = _f_timer@0
                    f_timer_Print                 = _f_timer_Print@8                       f_timer_Start
= _f_timer_Start@4                       f_timer_Stop                  = _f_timer_Stop@4                        f_tree
                     = _f_tree@4                              f_tree_Close                  = _f_tree_Close@4
            f_tree_Create                 = _f_tree_Create@16                      f_tree_Find                   =
_f_tree_Find@8                        f_tree_GetQueryStatistics_GetCounter_GetValue=
_f_tree_GetQueryStatistics_GetCounter_GetValue@4        f_tree_GetQueryStatistics_GetCounter_Reset=
_f_tree_GetQueryStatistics_GetCounter_Reset@4        f_tree_Insert                 = _f_tree_Insert@8
   f_tree_PrintInfo              = _f_tree_PrintInfo@4
 

3. Creating the .a file from dll by using:
  dlltool --dllname rtreewrapper.dll --def rtreewrapper.def --output-lib rtreewrapper.a

4. Compiling the whole AM module with makefile containing following line:
  OBJS =       atomrtget.o atomrtree.o atomrtscan.o atomrtcostestimate.o rtreewrapper.a

5. Copy the dll to the bin directory (when I let it in the contrib
directory, where also the libatomrtree.dll file with the AM functions
is, so it writes out, that the modul can't be found, when loading it).

6. When there is "void *header = f_header()" anywhere in the source,
so when trying to load the dll (when I try to create the index), it
writes out, that "function can't be found" (I got czech version, so I'm
not sure, what the message is in english).


Does anybody got any hint, where the problem could be? I really can't
find it:((

Thanks.

David Hoksza  
  



Re: using dll in am

От
Tom Lane
Дата:
David Hoksza <david.hoksza@seznam.cz> writes:
> I do following steps:

> 1. Compiling the dll in Microsoft Visual Studio.
> 2. Creating the def file (in mingw32):

I don't think you can use VS for building PG shared libraries --- it's
got incompatible conventions about symbol spelling, or some such.
There are more details in the pgsql-hackers-win32 archives I think.
        regards, tom lane


Re: using dll in am

От
"Magnus Hagander"
Дата:
> 5. Copy the dll to the bin directory (when I let it in the
> contrib directory, where also the libatomrtree.dll file with
> the AM functions is, so it writes out, that the modul can't
> be found, when loading it).
>
> 6. When there is "void *header = f_header()" anywhere in the
> source, so when trying to load the dll (when I try to create
> the index), it writes out, that "function can't be found" (I
> got czech version, so I'm not sure, what the message is in english).
>
>
> Does anybody got any hint, where the problem could be? I
> really can't find it:((

If I get you right, you have *two* DLLs? One in mingw that in turn loads
another one that's in VC++? If so, a couple of hints:

1) Run "depends" on the mingw DLL. It will list symbols that can't be
resolved. "depends" is a part of the Windows Support Tools, on your
windows CD.

2) Check that you can create a mingw *exe* that uses the functions in
the VC++ DLL. If not, make sure that works first, because that should be
easier to tweak.

//Magnus


Re: using dll in am

От
David Hoksza
Дата:
Yes, you got me right. I'm just trying the 2) and it doesn't work. So
I'll try the "depends" tool.
Thx,
David

________________________________
23. dubna 2006, 20:05:00, napsal jste:

>> 5. Copy the dll to the bin directory (when I let it in the 
>> contrib directory, where also the libatomrtree.dll file with 
>> the AM functions is, so it writes out, that the modul can't 
>> be found, when loading it).
>> 
>> 6. When there is "void *header = f_header()" anywhere in the 
>> source, so when trying to load the dll (when I try to create 
>> the index), it writes out, that "function can't be found" (I 
>> got czech version, so I'm not sure, what the message is in english).
>> 
>> 
>> Does anybody got any hint, where the problem could be? I 
>> really can't find it:((

MH> If I get you right, you have *two* DLLs? One in mingw that in turn loads
MH> another one that's in VC++? If so, a couple of hints:

MH> 1) Run "depends" on the mingw DLL. It will list symbols that can't be
MH> resolved. "depends" is a part of the Windows Support Tools, on your
MH> windows CD.

MH> 2) Check that you can create a mingw *exe* that uses the functions in
MH> the VC++ DLL. If not, make sure that works first, because that should be
MH> easier to tweak.

MH> //Magnus



Re: using dll in am

От
David Hoksza
Дата:
Uff, I finally got it. It's very simple. I was trying to use dlltool
all the time, but the solution is much simplier - just use directly
the .lib file with gcc and it will handle it. So easy that it didn't
cross my mind:)

gcc "....." atomrtget.o atomrtree.o atomrtscan.o atomrtcostestimate.o rtreewrapper.lib

Thanks,
David

________________________________
23. dubna 2006, 20:05:00, napsal jste:

>> 5. Copy the dll to the bin directory (when I let it in the 
>> contrib directory, where also the libatomrtree.dll file with 
>> the AM functions is, so it writes out, that the modul can't 
>> be found, when loading it).
>> 
>> 6. When there is "void *header = f_header()" anywhere in the 
>> source, so when trying to load the dll (when I try to create 
>> the index), it writes out, that "function can't be found" (I 
>> got czech version, so I'm not sure, what the message is in english).
>> 
>> 
>> Does anybody got any hint, where the problem could be? I 
>> really can't find it:((

MH> If I get you right, you have *two* DLLs? One in mingw that in turn loads
MH> another one that's in VC++? If so, a couple of hints:

MH> 1) Run "depends" on the mingw DLL. It will list symbols that can't be
MH> resolved. "depends" is a part of the Windows Support Tools, on your
MH> windows CD.

MH> 2) Check that you can create a mingw *exe* that uses the functions in
MH> the VC++ DLL. If not, make sure that works first, because that should be
MH> easier to tweak.

MH> //Magnus