[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Delphi/Kylix & NetCDF
- Subject: Re: Delphi/Kylix & NetCDF
- Date: Wed, 9 Jan 2002 07:55:34 -0700
hi john:
i do support netcdf on windows, but i know little about delphi
unfortunately. We do not have that environment, so its impossible for me to
test the problem.
i do know that delphi, being in pascal, has to establish linking conventions
into C/C++ code. I assume that is what the "unit created by Sandy Ballard"
does. I am appending a message below that is somewhat similar to your
problem.
i would post your question to netcdfgroup and directly to Sandy
(address@hidden), or to Jose (address@hidden) as it seem likely they
may know more about it that me.
PS: you might consider using C or Java instead. Borland has good IDEs for
both. Pascal is rather dated and little new development occurs in it,
although Delphi has cetainly been successful.
--------------
Date: Thu, 8 Feb 2001 10:19:58 +0100
From: =?iso-8859-1?Q?Jos=E9_Mar=EDa_Gonz=E1lez_Ondina?=
<address@hidden>
Subject: Re: problem using netcdf and Borland Delphi
> I am trying to read some cdf data files using Borland Delphi v 5.0 on a
> Windows NT machine. I downloaded netcdf.dll from the unidata ftp site
>
(ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-3.5-beta5.win32b
> in.ZIP) and put the following definitions in my Delphi code:
>
> function nc_inq_libvers : pchar; external 'netcdf.DLL';
> function nc_strerror (ncerr : integer) : pchar; external 'netcdf.DLL';
> function nc_open (path : pchar; omode : integer; var ncidp : integer) :
> integer; external 'netcdf.DLL';
> function nc_close (ncidp : integer) : integer; external 'netcdf.DLL';
>
> When I call nc_inq_libvers I get what appears (?) to be a reasonable
answer:
>
> 3.5-beta5 of Oct 17 2000 10:28:35 $
>
> but when I call nc_strerror with any integer (I tried a lot of them), I
> always get back
I think the problem can be in the calling convention and perhaps with
the
type of the parameter.
I have been mixing Delphi with DLLs made in Visual C++, and here is an
examples of external function declaration, perhaps it may help you.
Delphi Declaration:
function SetValue(Variable: PChar; VariableLength: Cardinal;
Value: PChar; ValueLength: Cardinal;
var Index, ValueType: Cardinal): Integer; cdecl;
external 'Intermed.dll';
DLL C++ declaration:
#define DllExport extern "C" __declspec( dllexport )
enum TValueType {vtNone=0, vtReal, vtInteger, vtString, vtRealVector};
DllExport int SetValue(char *Variable, unsigned int VariableLength,
char *Value, unsigned int ValueLength, int
*Index,
TValueType *ValueType);
As you can see, C++'s ints have been replaced by Delphi's Cardinal,
and
the calling convention have been set to "cdecl".
The only way I know to determine which calling convention you have to
use
and which are the types that match C++ (or other languages) types is
test
and error (and sometimes a little of inspection of the CPU window).
By the way, I am very interested in use NetCDF from Delphi in the
future,
but now I don´t have the time to do the porting. I'll like very much if
you
keep me informed of your progress.
Of course, if I can help you just write me.
José María González Ondina.
address@hidden
------------------------------
Date: Thu, 08 Feb 2001 14:06:17 +0100
From: Catrin Pieri <address@hidden>
Subject: Delphi and NetCDF
Dear Sandy,
You should use cdecl; as calling convention. See Delphi help for
details.
e.g. i use :
function nc_open(const path : Pchar; mode : integer; var ncidp :
integer):integer; cdecl; external 'netcdf.dll';
which works fine with Version 3.4 of NetCDF but the version should not
be
relevant.
Best regards Catrin
- --
____________________________________________________________________________
Catrin Pieri
HYDROMOD Wissenschaftliche Beratung GbR -- HYDROMOD Scientific
Consulting
Büroadresse / Office address: Bahnhofstr. 52, D-22880 Wedel
Postanschrift / Postal Address: Postfach 1229, D-22871 Wedel
Tel.: 04103 / 9 12 23-0 Fax: 04103 / 9 12 23-23
mailto:address@hidden http://www.hydromod.de
____________________________________________________________________________
------------------------------
End of ncdigest V1 #574
***********************
----- Original Message -----
From: "John Zbesko" <address@hidden>
To: <address@hidden>
Sent: Tuesday, January 08, 2002 9:29 PM
Subject: Delphi/Kylix & NetCDF
> Mr. Caron,
>
> A response from Russ Rew stated that you are the resident expert with
Delphi
> and that he was going to forward my inquiry to you. I'm taking the liberty
> of directly contacting you with the specific problems I've been having
> developing a financial application using NetCDF and Delphi/Kylix. Your
help
> is greatly appreciated.
>
> I'm working with Delphi with Win2000 because the shared library produced
> under linux does not work with Kylix. Russ stated that a specific compiler
> flag need be set for a shared library (*.so) to be produced. I tried an
> option mentioned in the man pages (-share), but apparently the gcc/cpp
> compiler does not support this flag. Russ mentioned the use of some tool
> called libtool, but I don't know how I could use it.
>
> So, I'm working with Delphi and have been successful in linking/using the
> netcdf.dll library. I am also using unit created by Sandy Ballard, listed
in
> the netcdfgroup archive.
>
> Unfortunately, several of the functions do not seem to work right.
> Specifically:
>
> nc_inq_dimname does not return any text of the name of a dimension,
>
> nc_def_var does not accept an array of integers for multiple dimensions
when
> defining a variable. I am only able to create a single dimension variable.
>
> Please forgive me if indeed these functions work and the real problem is
> that I don't know how to use them properly. I am choosing Delphi/Kylix for
> its IDE, as I am a beginning programmer.
>
> Again, thank you for any help or advice you can give me.
>
> Sincerely,
>
> John Zbesko, CFA
> address@hidden
>
>
>