Page 1 of 1

How to call a DLL ?

PostPosted: Wed May 10, 2006 9:13 am
by Raymond Fischbach
Hello,

I have to interface a DLL within a FWPPC program. Here follows the VB call to the function:

Code: Select all  Expand view
Public Declare Sub LatLon_WGS84_2_LT1 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double)


I have never done it so I don't know how to translate this into FWPPC.

Can someone help me ?

Thanks

Re: How to call a DLL ?

PostPosted: Wed May 10, 2006 9:38 am
by Enrico Maria Giordano
Have a look at DLL command.

EMG

PostPosted: Wed May 10, 2006 9:54 am
by Antonio Linares
Raymond,

You need to build a wrapper using C language as the parameters suply using DLL command is not ready yet. Please do a search on these forums for #pragma BEGINDUMP and you will find many samples.

PostPosted: Wed May 10, 2006 10:34 am
by Raymond Fischbach
Thank you.

I have never done it. I have never programmed in C either.
Anyway, I will have to try it.

PostPosted: Fri May 12, 2006 9:55 am
by Antonio Linares
Raymond,

First of all, you have to create an import library from "wdgps.dll", in two steps:

(impdef.exe is provided with free Borland C++, you may get it from ftp://ftpd.borland.com/download/bcppbui ... etools.exe)

1. impdef.exe wdgps.def wdgps.dll

that will create a wdgps.def file

2. lib.exe /OUT:wdgps.lib /DEF:wdgps.def

that will create a wdgps.lib

Please try it and check if you get the lib file.

PostPosted: Fri May 12, 2006 12:12 pm
by Raymond Fischbach
Thank you Antonio,

I will do it

PostPosted: Thu May 18, 2006 6:23 pm
by Raymond Fischbach
Hello Antonio,

I used Borland impdef.exe and then VCE lib.exe.
All seems to be ok and i have the wdgps_ce.lib file.

What should I do now ?

Thanks for your help,
Raymond

PostPosted: Fri May 19, 2006 9:51 am
by Antonio Linares
Raymond,
Code: Select all  Expand view
#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( CNVDEGTOXY )
{
   double dX = hb_parnd( 3 ), dY = hb_parnd( 4 );

   LatLon_WGS84_2_LT1( hb_parnd( 1 ), hb_parnd( 2 ), &dX, &dY );

   hb_stornd( dX, 3 );
   hb_stornd( dY, 4 );
}

#pragma ENDDUMP

Remember to link the library that you have created.

PostPosted: Fri May 19, 2006 11:13 am
by Raymond Fischbach
Many thanks,

I will post the results after my tests.

Regards, Saludos,
Raymond

PostPosted: Thu Jun 01, 2006 10:53 am
by Raymond Fischbach
It still doesn't work :(

Here is what i did:
- converted the DLL into a LIB following the directives from Antonio.
- added the wrapper into my code

- modified the Buildce.bat file to include the lib:
echo c:\FWPPC\GPS\UTM\wdgps_ce.lib >> msvc.tmp
The resulting msvc.tmp file contains the line:
c:\FWPPC\GPS\UTM\wdgps_ce.lib

- compile and link
I get the following errors:
Gps.prg(637) : error C2065: 'LatLon_WGS84_2_LT72' : undeclared identifier
Gps.prg(671) : error C2065: 'LatLon_WGS84_2_UTM_NAD83' : undeclared identifier

I found that I probably did the DLL - LIB conversion badly as I did not specified the processor type. Then I changed the call by adding the /MACHINE:ARM parameter to it.

But I get the same result.

What did I mis ?

Thanks for any help