perhaps some one could help with the following:
I'm trying to integrate a DELPHI work of college with my SciLab
script. I have de DLL but now i don't know how to continue... I've
seen the C/fortran example, tried to do similar call but nothing. I'm
a (TOTAL) newbie in the area of call's to DLL. Can any one help me?
A test delphi code is:
library DLLtest1;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
View-Project Source) USES clause if your DLL exports any procedures
or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the DELPHIMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using DELPHIMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
ShareMem,SysUtils,Classes;
function DIV2byte1(v:byte):byte;register;
begin
DIV2byte1:=v div 2
end;
function DIV2byte2(v:byte):byte;pascal;
begin
DIV2byte2:=v div 2
end;
function DIV2byte3(v:byte):byte;cdecl;
begin
DIV2byte3:=v div 2
end;
function DIV2byte4(v:byte):byte;stdcall;
begin
DIV2byte4:=v div 2
end;
function DIV2byte5(v:byte):byte;safecall;
begin
DIV2byte5:=v div 2
end;
exports DIV2byte1;
exports DIV2byte2;
exports DIV2byte3;
exports DIV2byte4;
exports DIV2byte5;
begin
end.
Thank you all.
Best regards,
Swarm.
Yes , you can call a delphi dll from scilab.
But your dll need to use stdcall convention for functions & procedures
that you want to export
(http://en.wikipedia.org/wiki/X86_calling_conventions)
Delphi doesn't use stdcall by default.
Example :
procedure mynewfunc; stdcall
begin
end
Best Regards
Allan CORNET
Scilab Team
Newbie regards,
Swarm.
On Nov 3, 7:39 am, allan.cor...@inria.fr wrote:
I used lazarus to compile the delphi code
/********************************/
library Project1;
{$mode objfpc}{$H+}
uses
SysUtils,Classes;
function DIV2byte4(v:byte):byte;stdcall;
begin
DIV2byte4:=v div 2
end;
exports DIV2byte4;
begin
end.
/********************************/
Then I went into Scilab and coded
cd "/home/...."
link('libteste')
call('DIV2byte4',2,1);
Now I have the following error
/***********
link('libtest')
!-- error236
link: the shared library was not loaded
at line: 2 of exec file called by
exec('/tmp/xpto/test.sce')
in execstr instruction called by:
/***********
Any ideas how to solve this?
Best regards,
Swarm.
export LD_LIBRARY_PATH=/home/swarm:$LD_LIBRARY_PATH
YC