linking to dll still fails

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

linking to dll still fails

Marc Santhoff
Hi,

I still have no success in linking against a dll on windows.

The dll import source looks like this:

...
{$linklib 'hdf5'}
...
function H5open:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;
function H5close:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;
...

and compiles okay.

The demo program used for testing does the obvious:

...
uses {$ifdef FreeBSD} BaseUnix { size_t an friends }, {$endif}
     hdf5;
...

and uses functions normally as declared in the unit hdf5.

On FreeBSD this works as expected, on window it doesn't. Using -vv gave
(shortened, can be posted in full lenght):

00008000:Searching file D:\FPC\2.2.0\units\i386-win32\.\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
00008000:Searching file hdf5.dll... found
....

00008000:Searching file D:\FPC\2.2.0\units\i386-win32\.\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
10000002:Error: Import library not found for hdf5

...

00020000:Number of unresolved externals in objects 123
00020000:Number of unresolved externals after static libraries 123
00020000:Number of unresolved externals after defining COMMON symbols 123
00020000:Number of unresolved externals after DLL imports 55
10000002:Error: Undefined symbol: _H5Aopen_name
10000002:Error: Undefined symbol: _H5Aget_type
10000002:Error: Undefined symbol: _H5Aget_space
10000002:Error: Undefined symbol: _H5Sget_simple_extent_ndims
10000002:Error: Undefined symbol: _H5Sget_simple_extent_dims
10000002:Error: Undefined symbol: _H5Tget_class
10000002:Error: Undefined symbol: _H5Sget_simple_extent_npoints
10000002:Error: Undefined symbol: HDF5_H5AREAD$LONGINT$LONGINT$POINTER$$LONGINT
10000002:Error: Undefined symbol: _H5Tclose
10000002:Error: Undefined symbol: _H5Sclose
...

I have only adjusted some basic functions to use stdcall instead of
cdecl on windows, so ignore the lines about undefined symbols having an
underscore at the start.

The dll is in the program directory. And it does get found. Another
issue might be:

in the units target dir there are three files:

-rw-rw-rw-   1 user     group       77104 Jun  7 05:45 hdf5.o
-rw-rw-rw-   1 user     group      154410 Jun  7 05:45 hdf5.ppu
-rw-rw-rw-   1 user     group           8 Jun  7 05:45 libimphdf5.a

If I assume the libimphdf5.a is the missing import library and look at
it:

!<arch>

That's in there, nothing else (8 bytes).

What's going wrong here, how can I make it work?

TIA,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Michael Van Canneyt


On Sat, 7 Jun 2008, Marc Santhoff wrote:

> Hi,
>
> I still have no success in linking against a dll on windows.
>
> The dll import source looks like this:
>
> ...
> {$linklib 'hdf5'}

You should change this to {$linklib hdf5.dll} for windows. Otherwise the compiler
will try to link to a static library.

> ...
> function H5open:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;
> function H5close:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;


It would be better to have

function H5close:herr_t;{$ifndef windows}cdecl{$else}stdcall{$endif};external;

This way it will also work on Linux, and Mac OS X.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Marc Santhoff
Am Samstag, den 07.06.2008, 10:24 +0200 schrieb Michael Van Canneyt:

>
> On Sat, 7 Jun 2008, Marc Santhoff wrote:
>
> > Hi,
> >
> > I still have no success in linking against a dll on windows.
> >
> > The dll import source looks like this:
> >
> > ...
> > {$linklib 'hdf5'}
>
> You should change this to {$linklib hdf5.dll} for windows. Otherwise the compiler
> will try to link to a static library.

Nice pitfall, I didn't find that in the docs.

But however, it did not make a change (see below). Meanwhile I adapted
the import statemments to be sure, but it doesn't help.

Another part is to adapt the declaration of variables. Currently they
are defined like this:

H5T_NATIVE_SCHAR_g : hid_t;cvar;external;

and as you can see in the fpcdebug.txt the name mangling is wrong:

10000002:Error: Undefined symbol: _H5T_NATIVE_SCHAR_g

How does it have to be defined for Windows?

> > ...
> > function H5open:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;
> > function H5close:herr_t;{$ifdef BSD}cdecl{$endif}{$ifdef Win32}stdcall{$endif};external;
>
>
> It would be better to have
>
> function H5close:herr_t;{$ifndef windows}cdecl{$else}stdcall{$endif};external;
>
> This way it will also work on Linux, and Mac OS X.

Maybe, HDF5 is very configuration dependant, but good hint, I'll do it
that way. :)

Thanks,
Marc

P.S.:
Here is a big part of the -vv output (I fear more than 40kB won't pass
to the list):

FPC bug report file
00020000:Handling option "-di386"
00020000:interpreting firstpass option "-di386"
10010000:Macro defined: I386
10010000:Macro defined: WIN32
10010000:Macro defined: FPC
10010000:Macro defined: VER2
10010000:Macro defined: VER2_2
10010000:Macro defined: VER2_2_0
10010000:Macro defined: FPC_DARWIN_PASCALMAIN
10010000:Macro defined: FPC_DARWIN_JMP_MAIN
10010000:Macro defined: COMPPROCINLINEFIXED
10010000:Macro defined: PARAOUTFILE
10010000:Macro defined: RESSTRSECTIONS
10010000:Macro defined: FPC_HASFIXED64BITVARIANT
10010000:Macro defined: FPC_HASINTERNALOLEVARIANT2VARIANTCAST
10010000:Macro defined: FPC_HAS_VARSETS
10010000:Macro defined: FPC_HAS_VALGRINDBOOL
10010000:Macro defined: FPC_HAS_STR_CURRENCY
10010000:Macro defined: FPC_REAL2REAL_FIXED
10010000:Macro defined: FPC_STRTOCHARARRAYPROC
10010000:Macro defined: FPC_SUPPORTS_UNALIGNED
10010000:Macro defined: INTERNAL_BACKTRACE
10010000:Macro defined: STR_CONCAT_PROCS
10010000:Macro defined: REGCALL
10010000:Macro defined: FPC_HAS_FEATURE_SUPPORT
10010000:Macro defined: CPU86
10010000:Macro defined: CPU87
10010000:Macro defined: CPU386
10010000:Macro defined: CPUI386
10010000:Macro defined: CPU32
10010000:Macro defined: FPC_HAS_TYPE_EXTENDED
10010000:Macro defined: FPC_HAS_TYPE_DOUBLE
10010000:Macro defined: FPC_HAS_TYPE_SINGLE
10010000:Macro defined: FPC_HAS_RESOURCES
10010000:Macro defined: FPC_WINLIKEWIDESTRING
00008000:Configfile search: fpc.cfg
00008000:Configfile search: D:\FPC\2.2.0\BIN\I386-WIN32\fpc.cfg
00008000:Reading options from file D:\FPC\2.2.0\BIN\I386-WIN32\fpc.cfg
10000020:Start of reading config file D:\FPC\2.2.0\BIN\I386-WIN32\fpc.cfg
00020000:interpreting file option "#"

[... standard config file skipped ...]

00020000:Handling option "-viwn"
00020000:interpreting option "-viwn"
00020000:interpreting file option "# If you don't want so much verbosity use"
00020000:interpreting file option "#-vw"
10000020:End of reading config file D:\FPC\2.2.0\BIN\I386-WIN32\fpc.cfg
00020000:Handling option "-vv"
00020000:interpreting option "-vv"
00020000:Handling option "-Fud:/fpc/2.2.0/units/i386-win32/rtl"
00020000:interpreting option "-Fud:/fpc/2.2.0/units/i386-win32/rtl"
00020000:Handling option "-Fud:/fpc/2.2.0/units/i386-win32/hdf5"
00020000:interpreting option "-Fud:/fpc/2.2.0/units/i386-win32/hdf5"
00020000:Handling option "-FE."
00020000:interpreting option "-FE."
00020000:Handling option "-FUunits/i386-win32"
00020000:interpreting option "-FUunits/i386-win32"
00020000:Handling option "-di386"
00020000:interpreting option "-di386"
00020000:Handling option "h5_attribute.pas"
00020000:found source file name "h5_attribute.pas"
10000004:Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
10000004:Copyright (c) 1993-2007 by Florian Klaempfl
10010000:Macro defined: MSWINDOWS
10010000:Macro defined: WINDOWS
10010000:Macro defined: ENDIAN_LITTLE
10010000:Macro defined: FPC_LITTLE_ENDIAN
10010000:Macro defined: CPUPENTIUM
10010000:Macro defined: FPUX87
10010000:Macro defined: FPC_LINK_STATIC
10010000:Macro FPC_VERSION set to 2
10010000:Macro FPC_RELEASE set to 2
10010000:Macro FPC_PATCH set to 0
10010000:Macro defined: FPC_HAS_FEATURE_HEAP
10010000:Macro defined: FPC_HAS_FEATURE_INITFINAL
10010000:Macro defined: FPC_HAS_FEATURE_RTTI
10010000:Macro defined: FPC_HAS_FEATURE_CLASSES
10010000:Macro defined: FPC_HAS_FEATURE_EXCEPTIONS
10010000:Macro defined: FPC_HAS_FEATURE_EXITCODE
10010000:Macro defined: FPC_HAS_FEATURE_ANSISTRINGS
10010000:Macro defined: FPC_HAS_FEATURE_WIDESTRINGS
10010000:Macro defined: FPC_HAS_FEATURE_TEXTIO
10010000:Macro defined: FPC_HAS_FEATURE_CONSOLEIO
10010000:Macro defined: FPC_HAS_FEATURE_FILEIO
10010000:Macro defined: FPC_HAS_FEATURE_RANDOM
10010000:Macro defined: FPC_HAS_FEATURE_VARIANTS
10010000:Macro defined: FPC_HAS_FEATURE_OBJECTS
10010000:Macro defined: FPC_HAS_FEATURE_DYNARRAYS
10010000:Macro defined: FPC_HAS_FEATURE_THREADING
10010000:Macro defined: FPC_HAS_FEATURE_COMMANDARGS
10010000:Macro defined: FPC_HAS_FEATURE_PROCESSES
10010000:Macro defined: FPC_HAS_FEATURE_STACKCHECK
00008000:Compiler: D:\FPC\2.2.0\BIN\I386-WIN32\PPC386.EXE
00020000:Compiler OS: Win32 for i386
00001000:Target OS: Win32 for i386
00008000:Using executable path: D:\FPC\2.2.0\BIN\I386-WIN32\
00008000:Using unit path: D:\fpc\2.2.0\units\i386-win32\rtl\
00008000:Using unit path: D:\fpc\2.2.0\units\i386-win32\hdf5\
00008000:Using unit path: D:\FPC\2.2.0\units\i386-win32\zlib\

[...]

00008000:Using object path: D:\FPC\2.2.0\units\i386-win32\.\
00008000:Using object path: D:\FPC\2.2.0\units\i386-win32\
00008000:Using object path: D:\FPC\2.2.0\BIN\I386-WIN32\
00001000:Compiling h5_attribute.pas
00008000:Searching file h5_attribute.pas... found
10010000:h5_attribute.pas(40,8)  IFDEF FREEBSD found, rejected
10010000:h5_attribute.pas(40,16)  Skipping until...
10020000:h5_attribute.pas(42,8)  Handling switch "$ENDIF"
10010000:h5_attribute.pas(42,8)  ENDIF FREEBSD found
10010000:h5_attribute.pas(44,9)  IFNDEF WIN32 found, rejected
10010000:h5_attribute.pas(44,15)  Skipping until...
10020000:h5_attribute.pas(46,7)  Handling switch "$ELSE"
10010000:h5_attribute.pas(46,7)  ELSE WIN32 found, accepted
10020000:h5_attribute.pas(47,4)  Handling switch "$LINKLIB"
10010000:h5_attribute.pas(48,8)  ENDIF WIN32 found
00004000:Registering new unit SYSTEM
00004000:Load from H5_ATTRIBUTE (implementation) unit SYSTEM
00004000:Loading unit SYSTEM
00008000:Unitsearch: System.ppu
00008000:Searching file System.ppu... not found
00008000:Unitsearch: units\i386-win32\System.ppu
00008000:Searching file units\i386-win32\System.ppu... not found
00008000:Unitsearch: System.pp
00008000:Searching file System.pp... not found
00008000:Unitsearch: System.pas
00008000:Searching file System.pas... not found
00008000:Unitsearch: System.ppu
00008000:Searching file System.ppu... not found
00008000:Unitsearch: System.pp
00008000:Searching file System.pp... not found
00008000:Unitsearch: System.pas
00008000:Searching file System.pas... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\rtl\System.ppu
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\System.ppu... found
00008000:PPU Loading D:\fpc\2.2.0\units\i386-win32\rtl\System.ppu
00004000:PPU Name: D:\fpc\2.2.0\units\i386-win32\rtl\System.ppu
00004000:PPU Time: 2007/09/09 20:20:16
00004000:PPU Flags: 159873
00004000:PPU Crc: C32CD640
00004000:PPU Crc: 760B998C (intfc)
00004000:Number of definitions: 3065
00004000:Number of symbols: 8087
00004000:Finished loading unit SYSTEM
00008000:Searching file h5_attribute.pas... found
10010000:h5_attribute.pas(50,13)  IFDEF FREEBSD found, rejected
10010000:h5_attribute.pas(50,21)  Skipping until...
10020000:h5_attribute.pas(50,62)  Handling switch "$ENDIF"
10010000:h5_attribute.pas(50,62)  ENDIF FREEBSD found
00004000:Registering new unit HDF5
00004000:Load from H5_ATTRIBUTE (implementation) unit HDF5
00004000:Loading unit HDF5
00008000:Unitsearch: hdf5.ppu
00008000:Searching file hdf5.ppu... not found
00008000:Unitsearch: units\i386-win32\hdf5.ppu
00008000:Searching file units\i386-win32\hdf5.ppu... not found
00008000:Unitsearch: hdf5.pp
00008000:Searching file hdf5.pp... not found
00008000:Unitsearch: hdf5.pas
00008000:Searching file hdf5.pas... not found
00008000:Unitsearch: hdf5.ppu
00008000:Searching file hdf5.ppu... not found
00008000:Unitsearch: hdf5.pp
00008000:Searching file hdf5.pp... not found
00008000:Unitsearch: hdf5.pas
00008000:Searching file hdf5.pas... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.ppu
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.ppu... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.pp
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.pp... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.pas
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.pas... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.ppu
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.ppu... found
00008000:PPU Loading D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.ppu
00004000:PPU Name: D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.ppu
00004000:PPU Time: 2008/06/07 12:04:16
00004000:PPU Flags: 151681
00004000:PPU Crc: 425BF95B
00004000:PPU Crc: 1EE335A1 (intfc)
00004000:Number of definitions: 505
00004000:Number of symbols: 1894
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\hdf5.pas... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.pas... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\zlib\hdf5.pas... not found

[...]

00008000:Searching file D:\FPC\2.2.0\units\i386-win32\.\hdf5.pas... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\hdf5.pas... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\hdf5.pas... not found
00004000:PPU Source: hdf5.pas not found
00004000:Load from HDF5 (interface) unit SYSTEM
00004000:Add dependency of HDF5 to SYSTEM
00004000:Finished loading unit HDF5
00008000:Searching file h5_attribute.pas... found
10004000:h5_attribute.pas(53,1)  Parsing implementation of h5_attribute.pas
10020000:h5_attribute.pas(102,1)  procedure/function attr_info(LongInt,const PChar, Pointer):LongInt;CDecl
10000010:h5_attribute.pas(106,2) Note: Local variable "ret" is assigned but never used
10000020:h5_attribute.pas(101,53)  Parameter "opdata" not used
10000010:h5_attribute.pas(82,2) Note: Local variable "ret" is assigned but never used
10000010:h5_attribute.pas(84,2) Note: Local variable "idx" is assigned but never used
00004000:Registering new unit SYSINITPAS
00004000:Load from H5_ATTRIBUTE (implementation) unit SYSINITPAS
00004000:Loading unit SYSINITPAS
00008000:Unitsearch: sysinitpas.ppu
00008000:Searching file sysinitpas.ppu... not found
00008000:Unitsearch: units\i386-win32\sysinitpas.ppu
00008000:Searching file units\i386-win32\sysinitpas.ppu... not found
00008000:Unitsearch: sysinitpas.pp
00008000:Searching file sysinitpas.pp... not found
00008000:Unitsearch: sysinitpas.pas
00008000:Searching file sysinitpas.pas... not found
00008000:Unitsearch: sysinitpas.ppu
00008000:Searching file sysinitpas.ppu... not found
00008000:Unitsearch: sysinitpas.pp
00008000:Searching file sysinitpas.pp... not found
00008000:Unitsearch: sysinitpas.pas
00008000:Searching file sysinitpas.pas... not found
00008000:Unitsearch: D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.ppu
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.ppu... found
00008000:PPU Loading D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.ppu
00004000:PPU Name: D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.ppu
00004000:PPU Time: 2007/09/09 20:20:16
00004000:PPU Flags: 159872
00004000:PPU Crc: F2708CB4
00004000:PPU Crc: F2708CB4 (intfc)
00004000:Number of definitions: 22
00004000:Number of symbols: 23
00004000:Load from SYSINITPAS (interface) unit SYSTEM
00004000:Add dependency of SYSINITPAS to SYSTEM
00004000:Finished loading unit SYSINITPAS
00008000:Searching file h5_attribute.pas... found
00008000:Searching file libhdf5.dll.a... not found
00008000:Searching file libhdf5.dll.a... not found
00008000:Searching file units\i386-win32\libhdf5.dll.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\libhdf5.dll.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\libhdf5.dll.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\zlib\libhdf5.dll.a... not found

[...]

00008000:Searching file D:\FPC\2.2.0\units\i386-win32\libhdf5.dll.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.dll.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.dll.a... not found
00008000:Searching file hdf5.dll... found
00008000:Searching file units\i386-win32\units\i386-win32\h5_attribute.o... not found
00008000:Searching file units\i386-win32\h5_attribute.o... found
00008000:Searching file units\i386-win32\libimph5_attribute.a... found
00008000:Searching file units\i386-win32\system.o... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\system.o... found
00008000:Searching file libimpsystem.a... not found
00008000:Searching file libimpsystem.a... not found
00008000:Searching file units\i386-win32\libimpsystem.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\libimpsystem.a... found
00008000:Searching file units\i386-win32\hdf5.o... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.o... found
00008000:Searching file libimphdf5.a... not found
00008000:Searching file libimphdf5.a... not found
00008000:Searching file units\i386-win32\libimphdf5.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\libimphdf5.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\libimphdf5.a... found
00008000:Searching file units\i386-win32\sysinitpas.o... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.o... found
00008000:Searching file libimpsysinitpas.a... not found
00008000:Searching file libimpsysinitpas.a... not found
00008000:Searching file units\i386-win32\libimpsysinitpas.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\libimpsysinitpas.a... found
00001000:Linking .\h5_attribute.exe
00008000:Searching file libhdf5.a... not found
00008000:Searching file libhdf5.a... not found
00008000:Searching file units\i386-win32\libhdf5.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\libhdf5.a... not found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\zlib\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\winunits\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\unzip\libhdf5.a... not found

[...]

00008000:Searching file D:\FPC\2.2.0\units\i386-win32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.a... not found
10000002:Error: Import library not found for hdf5
00008000:Searching file units\i386-win32\h5_attribute.o... found
00008000:Searching file units\i386-win32\h5_attribute.o... found
00008000:Reading object units\i386-win32\h5_attribute.o
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\system.o... found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\system.o... found
00008000:Reading object D:\fpc\2.2.0\units\i386-win32\rtl\system.o
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.o... found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.o... found
00008000:Reading object D:\fpc\2.2.0\units\i386-win32\hdf5\hdf5.o
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.o... found
00008000:Searching file D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.o... found
00008000:Reading object D:\fpc\2.2.0\units\i386-win32\rtl\sysinitpas.o
00020000:Number of unresolved externals in objects 123
00020000:Number of unresolved externals after static libraries 123
00020000:Number of unresolved externals after defining COMMON symbols 123
00020000:Number of unresolved externals after DLL imports 55
10000002:Error: Undefined symbol: HDF5_H5AOPEN_NAME$LONGINT$PCHAR$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5AGET_TYPE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5AGET_SPACE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5SGET_SIMPLE_EXTENT_NDIMS$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5SGET_SIMPLE_EXTENT_DIMS$LONGINT$PHSIZE_T$PHSIZE_T$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5TGET_CLASS$LONGINT$$H5T_CLASS_T
10000002:Error: Undefined symbol: HDF5_H5SGET_SIMPLE_EXTENT_NPOINTS$LONGINT$$INT64
10000002:Error: Undefined symbol: HDF5_H5AREAD$LONGINT$LONGINT$POINTER$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5TCLOSE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5SCLOSE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5ACLOSE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5FCREATE$PCHAR$LONGWORD$LONGINT$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5SCREATE$H5S_CLASS_T$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5SSET_EXTENT_SIMPLE$LONGINT$LONGINT$array_of_QWORD$PHSIZE_T$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5DCREATE$LONGINT$PCHAR$LONGINT$LONGINT$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5DWRITE$LONGINT$LONGINT$LONGINT$LONGINT$LONGINT$POINTER$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5ACREATE$LONGINT$PCHAR$LONGINT$LONGINT$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5AWRITE$LONGINT$LONGINT$POINTER$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5TCOPY$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5TSET_SIZE$LONGINT$LONGWORD$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5TSET_STRPAD$LONGINT$H5T_STR_T$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5DCLOSE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5FCLOSE$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5FOPEN$PCHAR$LONGWORD$LONGINT$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5DOPEN$LONGINT$PCHAR$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5AOPEN_IDX$LONGINT$LONGWORD$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5AITERATE$LONGINT$PDWORD$H5A_OPERATOR_T$POINTER$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5GLINK2$LONGINT$PCHAR$H5G_LINK_T$LONGINT$PCHAR$$LONGINT
10000002:Error: Undefined symbol: HDF5_H5OPEN$$LONGINT
10000002:Error: Undefined symbol: _H5T_NATIVE_SCHAR_g
10000002:Error: Undefined symbol: _H5T_NATIVE_UCHAR_g
10000002:Error: Undefined symbol: _H5T_NATIVE_SHORT_g
10000002:Error: Undefined symbol: _H5T_NATIVE_USHORT_g
10000002:Error: Undefined symbol: _H5T_NATIVE_INT_g
10000002:Error: Undefined symbol: _H5T_NATIVE_UINT_g
10000002:Error: Undefined symbol: _H5T_NATIVE_LONG_g
10000002:Error: Undefined symbol: _H5T_NATIVE_ULONG_g
10000002:Error: Undefined symbol: _H5T_NATIVE_LLONG_g
10000002:Error: Undefined symbol: _H5T_NATIVE_ULLONG_g
10000002:Error: Undefined symbol: _H5T_NATIVE_FLOAT_g
10000002:Error: Undefined symbol: _H5T_NATIVE_DOUBLE_g
10000002:Error: Undefined symbol: _H5T_NATIVE_LDOUBLE_g
10000002:Error: Undefined symbol: _H5T_NATIVE_B8_g
10000002:Error: Undefined symbol: _H5T_NATIVE_B16_g
10000002:Error: Undefined symbol: _H5T_NATIVE_B32_g
10000002:Error: Undefined symbol: _H5T_NATIVE_B64_g
10000002:Error: Undefined symbol: _H5T_NATIVE_OPAQUE_g
10000002:Error: Undefined symbol: _H5T_NATIVE_HADDR_g
10000002:Error: Undefined symbol: _H5T_NATIVE_HSIZE_g
10000001:Fatal: There were 50 errors compiling module, stopping
10000001:Fatal: Compilation aborted


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Michael Van Canneyt


On Sat, 7 Jun 2008, Marc Santhoff wrote:

> Am Samstag, den 07.06.2008, 10:24 +0200 schrieb Michael Van Canneyt:
> >
> > On Sat, 7 Jun 2008, Marc Santhoff wrote:
> >
> > > Hi,
> > >
> > > I still have no success in linking against a dll on windows.
> > >
> > > The dll import source looks like this:
> > >
> > > ...
> > > {$linklib 'hdf5'}
> >
> > You should change this to {$linklib hdf5.dll} for windows. Otherwise the compiler
> > will try to link to a static library.
>
> Nice pitfall, I didn't find that in the docs.
>
> But however, it did not make a change (see below). Meanwhile I adapted
> the import statemments to be sure, but it doesn't help.

Hm. what options did you specify on the command-line, and what options
are in the configuration files ?

>
> Another part is to adapt the declaration of variables. Currently they
> are defined like this:
>
> H5T_NATIVE_SCHAR_g : hid_t;cvar;external;
>
> and as you can see in the fpcdebug.txt the name mangling is wrong:
>
> 10000002:Error: Undefined symbol: _H5T_NATIVE_SCHAR_g
>
> How does it have to be defined for Windows?

No idea; it probably depends on the used C compiler ?


Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Marc Santhoff
In reply to this post by Marc Santhoff
Hi again,

I have more questions on linking. What can prevent dynamic linking from
being possible? Like in the following snippet from fpcdebug.txt:

00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.dll.a... not found
00008000:Searching file hdf5.dll... found
00008000:unit H5_ATTRIBUTE can't be shared linked, switching to static linking
                      ^^^^^^^^^^^
00008000:Searching file h5_attribute.o... found
00008000:Searching file libimph5_attribute.a... found
00008000:unit SYSTEM can't be shared linked, switching to static linking
                      ^^^^^^^^^^^
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\system.o... found
00008000:Searching file libimpsystem.a... not found
00008000:Searching file libimpsystem.a... not found
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\libimpsystem.a... not found
00008000:Searching file .\libimpsystem.a... not found
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\units\i386-win32\libimpsystem.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\libimpsystem.a... found
00008000:unit HDF5 can't be shared linked, switching to static linking
                      ^^^^^^^^^^^^
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\hdf5.o... found
00008000:Searching file libimphdf5.a... not found
00008000:Searching file libimphdf5.a... not found
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\libimphdf5.a... found
00008000:unit SYSINITPAS can't be shared linked, switching to static linking
                      ^^^^^^^^^^^^^
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\sysinitpas.o... found
00008000:Searching file libimpsysinitpas.a... not found
00008000:Searching file libimpsysinitpas.a... not found
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\libimpsysinitpas.a... not found
00008000:Searching file .\libimpsysinitpas.a... not found
00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\units\i386-win32\libimpsysinitpas.a... not found
00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\libimpsysinitpas.a... found
00001000:Linking h5_attribute.exe
00008000:Searching file libhdf5.a... not found

Is there any documentation on this topic?
Or maybe some hints how the reason that stops dynamic linking can be
found?

I'm amazed that this is an issue, I would never expect problems on such
matters ...

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Marc Santhoff
In reply to this post by Michael Van Canneyt
Am Sonntag, den 08.06.2008, 11:34 +0200 schrieb Michael Van Canneyt:

>
> On Sat, 7 Jun 2008, Marc Santhoff wrote:
>
> > Am Samstag, den 07.06.2008, 10:24 +0200 schrieb Michael Van Canneyt:
> > >
> > > On Sat, 7 Jun 2008, Marc Santhoff wrote:
> > >
> > > > Hi,
> > > >
> > > > I still have no success in linking against a dll on windows.
> > > >
> > > > The dll import source looks like this:
> > > >
> > > > ...
> > > > {$linklib 'hdf5'}
> > >
> > > You should change this to {$linklib hdf5.dll} for windows. Otherwise the compiler
> > > will try to link to a static library.
> >
> > Nice pitfall, I didn't find that in the docs.
> >
> > But however, it did not make a change (see below). Meanwhile I adapted
> > the import statemments to be sure, but it doesn't help.
>
> Hm. what options did you specify on the command-line, and what options
> are in the configuration files ?

I'm using a standard configuration as generated by the installation.
That is stripped down to active lines:

<fpc.cfg>
# Allow goto, inline, C-operators, C-vars
-Sgic

# searchpath for units and other system dependent things
-FuD:\FPC\2.2.0/units/$FPCTARGET/
-FuD:\FPC\2.2.0/units/$FPCTARGET/*
-FuD:\FPC\2.2.0/units/$FPCTARGET/rtl

# searchpath for tools
-FDD:\FPC\2.2.0/bin/$FPCTARGET

# Always strip debuginfo from the executable
-Xs

# Write always a nice FPC logo ;)
-l

# Display Info, Warnings, Notes and Hints
-viwn
</fpc.cfg>

aside with using

{$mode objfpc}{$H+}

{$ifndef win32}
  {$linklib hdf5}
{$else}
  {$linklib 'hdf5.dll'}
{$endif}

in the source of h5_attribute.pas. This is a demo for the hdf5 package
and both are made using fpcmake:

<main Makefile.fpc>
#
#   Makefile.fpc for HDF5 Bindings
#
programs=h5_attribute h5_compound h5_group h5_read h5_write \
         test_lite test_image test_table

[package]
name=hdf5
version=1.6.5

[target]
;units=hdf5 hdf5_hl
units=hdf5
programs=

exampledirs=demo

[compiler]
;options=-CX -Xi -XD
options=-vv

[require]
packages=
libc=y

[install]
fpcpackage=y
prefix=$(FPCDIR)

[default]
fpcdir=$(FPCDIR)

[shared]
build=n
</main Makefile.fpc>

<main/demo Makefile.fpc>
[target]
programs=h5_attribute h5_compound h5_group h5_read h5_write \
         test_lite test_image test_table

[require]
packages=hdf5

[install]
fpcpackage=y

[default]
fpcdir=$FPCDIR

[compiler]
;options=-CX -Xi -XD
;options=-vv -Fu.. -Fi..
options=-vv

</main/demo Makefile.fpc>

The variable $(FPCDIR) is set in the windows environment to the base of
the binary installation opf fpc:

        set FPCDIR=D:\fpc\2.2.0\

The package is built and installed and has (as mentioned somewhere) a
mostly empty limimphdf5.a.

> >
> > Another part is to adapt the declaration of variables. Currently they
> > are defined like this:
> >
> > H5T_NATIVE_SCHAR_g : hid_t;cvar;external;
> >
> > and as you can see in the fpcdebug.txt the name mangling is wrong:
> >
> > 10000002:Error: Undefined symbol: _H5T_NATIVE_SCHAR_g
> >
> > How does it have to be defined for Windows?
>
> No idea; it probably depends on the used C compiler ?

IIRC this is MSVC in version 6 or so. I'll look after that.

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Michael Van Canneyt
In reply to this post by Marc Santhoff


On Sun, 8 Jun 2008, Marc Santhoff wrote:

> Hi again,
>
> I have more questions on linking. What can prevent dynamic linking from
> being possible? Like in the following snippet from fpcdebug.txt:
>
> 00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.dll.a... not found
> 00008000:Searching file hdf5.dll... found
> 00008000:unit H5_ATTRIBUTE can't be shared linked, switching to static linking
                       ^^^^^^^^^^^
You should remove any -XS -XD -CX options you can find, they are causing this.

> 00008000:Searching file .\libimpsysinitpas.a... not found
> 00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\units\i386-win32\libimpsysinitpas.a... not found
> 00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\libimpsysinitpas.a... found
> 00001000:Linking h5_attribute.exe
> 00008000:Searching file libhdf5.a... not found
>
> Is there any documentation on this topic?
> Or maybe some hints how the reason that stops dynamic linking can be
> found?
>
> I'm amazed that this is an issue, I would never expect problems on such
> matters ...

Neither would I... Can you send me the sources if the problem persists after
getting rid of all 'wrong' options ?

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Marc Santhoff
In reply to this post by Marc Santhoff
Am Sonntag, den 08.06.2008, 12:35 +0200 schrieb Marc Santhoff:

> > > Another part is to adapt the declaration of variables. Currently they
> > > are defined like this:
> > >
> > > H5T_NATIVE_SCHAR_g : hid_t;cvar;external;
> > >
> > > and as you can see in the fpcdebug.txt the name mangling is wrong:
> > >
> > > 10000002:Error: Undefined symbol: _H5T_NATIVE_SCHAR_g
> > >
> > > How does it have to be defined for Windows?
> >
> > No idea; it probably depends on the used C compiler ?
>
> IIRC this is MSVC in version 6 or so. I'll look after that.

Maybe it's the initialization, that could be done in another way (e.g. a
separate unit if necessary):

<unit hdf5>
unit hdf5;
...
initialization

        { C has this in macros all over the place. Since it has to be done
          once we do it here before anything else happens and are happy :) }
        H5open();
       
        { Initialize standard type vars for copying }

        H5T_NATIVE_CHAR := H5T_NATIVE_SCHAR_g;
        H5T_NATIVE_SCHAR := H5T_NATIVE_SCHAR_g;
...
</unit hdf5>

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: linking to dll still fails

Marc Santhoff
In reply to this post by Michael Van Canneyt
Am Sonntag, den 08.06.2008, 12:52 +0200 schrieb Michael Van Canneyt:

>
> On Sun, 8 Jun 2008, Marc Santhoff wrote:
>
> > Hi again,
> >
> > I have more questions on linking. What can prevent dynamic linking from
> > being possible? Like in the following snippet from fpcdebug.txt:
> >
> > 00008000:Searching file D:\FPC\2.2.0\BIN\I386-WIN32\libhdf5.dll.a... not found
> > 00008000:Searching file hdf5.dll... found
> > 00008000:unit H5_ATTRIBUTE can't be shared linked, switching to static linking
>                        ^^^^^^^^^^^
> You should remove any -XS -XD -CX options you can find, they are causing this.

I'd say this has nothing to do with the problem then, I got those
message after trying to compile without the help of fpcmake and make.

fpc -Fu.. -Fl.. -Fl. -Fu..\units\i386-win32 -Fo.. -Xc -Xe -XD -k'-lhdf5'
-vv h5_attribute

Btw., testing used both, internal and external linker.

> > 00008000:Searching file .\libimpsysinitpas.a... not found
> > 00008000:Searching file D:\FPC\fpcbuild-2.2.0\fpcsrc\packages\extra\hdf5\units\i386-win32\libimpsysinitpas.a... not found
> > 00008000:Searching file D:\FPC\2.2.0\units\i386-win32\rtl\libimpsysinitpas.a... found
> > 00001000:Linking h5_attribute.exe
> > 00008000:Searching file libhdf5.a... not found
> >
> > Is there any documentation on this topic?
> > Or maybe some hints how the reason that stops dynamic linking can be
> > found?
> >
> > I'm amazed that this is an issue, I would never expect problems on such
> > matters ...
>
> Neither would I... Can you send me the sources if the problem persists after
> getting rid of all 'wrong' options ?

If anything else fails, yes, I can. But that may take a little while to
do some cleaning up from my testbed.

Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal