@Thaddy, works perfectly, would newer have tried that. Thank you very much.
Hmm, very puzzling. Now you have code that's incompatible with Delphi. That doesn't sound right at all.
I assume you got your function declaration from Beckhoff's TcAdsApi.pas. That should work the same with both Delphi and FPC.
http://infosys.beckhoff.com/english.php?content=../content/1033/tcadscomlib/html/tcadscomlib_intro.htmHave you tested with Delphi to see if it still works there? And what version of FPC are you using?
In my own tests, specifying the decorated function name is required if that's how the library entry point is named. For example, in this simple program that tests the GDAL library, it works fine with both Delphi and FPC 3.0.0. However, if I compile with either of the commented out declarations, I get the error message you posted above when the app is run.
program TestDecName;
type
cint = LongInt;
function GDALGetDriverCount: cint; stdcall; external 'gdal111.dll' name '_GDALGetDriverCount@0';
//function GDALGetDriverCount: cint; stdcall; external 'gdal111.dll' name 'GDALGetDriverCount';
//function GDALGetDriverCount: cint; stdcall; external 'gdal111.dll' name 'GDALGetDriverCount@0';
begin
WriteLn(GdalGetDriverCount);
end.
Another thing that's puzzling me is why your error message indicates that the project1.exe is the DLL.
Something going on here, I believe.