Linking Delphi DLL with Scilab

Thales Jacques thalesjacques at gmail.com
Tue May 15 03:44:39 CEST 2012


Hello Folks,

Here is the the solution for the problem (thank you for everybody that
posted parts of the puzzle):

1. Yes, you can link DLL's compiled in Delphi.

2. Make sure that you running a compatible version of Scilab. If the DLL is
32 bits, you must use Scilab 32 bits to link the DLL. You can run Scilab 32
bits in a 64 bits environment and link to a 32 bits DLL; this is not a
problem.

3. Use Dependency Walker (www.dependencywalker.com) to verify if your DLL is
exposing all the functions/procedures you need to execute. If you can not
see the function/procedure then it will not work in Scilab. Go back to
Delphi and re-compile.

4. Use:
cd C:\<path to your DLL>; //do this or just have the full path on the next
line
functions=["function1";"function2";]; //replace the strings by the name of
the function inside the DLL; no need for "_" or any other special character;
a=link('YourDLLName.dll',functions,'c');

here, if it returns an integer, you are good. You will see the message:

Shared archive loaded.
Link done.

If you have the message below, make sure you have the name of your function
correct. Dependency Walker can help with that.

Shared archive loaded.
Link done.
<Function Name> is not an entry point.
                                      !--error 235 
link: problem with one of the entry point.

If you see this other message below, make sure you are pointing to the
correct directory:

                                      !--error 236 
link: The shared archive was not loaded: The filename, directory name, or
volume label syntax is incorrect.

5. Use the command below to see if your library the correctly linked and
which functions/procedures are linked:

lstID = link("show");


6. lst = link() returns the functions that are linked.

7. ulink(a) will remove the link to your library. "a" is the integer
returned when you executed a=link('YourDLLName.dll',functions,'c') and you
can see the values for "a" in the vector returned by lstID = link("show");

8. Use call() to execute the function in your DLL. Go to the help for call
(for novices, just type "help call") to see how to use it. Yes, spend good
10 minutes trying to understand it. It is easy, but you will not learn in 5
seconds.
Tip: you must use a matrix to return the output of the function/procedure
you are calling. If it is just an integer, it will be a 1x1 matrix. Just
make sure you understand what "help call" is trying to teach you.

notes:
I had to re-install my 32 bits version of Scilab to make it work. I don't
know why.

I've been chasing this information for a good few days now. I hope this will
help some people in the future. I am still working on my project and I will
post updates here, if any.

 

--
View this message in context: http://mailinglists.scilab.org/Linking-Delphi-DLL-with-Scilab-tp3967008p3987186.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list