Hello James,

inputs arguments of your interface must be pointers, Scilab manage data as matrix ( arrays in C )
So a scalar variable `A` become a `double A[1];`

prototype must be like this :
void Add(double* a, double* b, double* c);


I made some changes is yours files, take a look, I hope that can help you.

Antoine

Le 2017-01-18 22:38, James Holland a écrit :
I've spent some time on this and I still can't get this to work. I've created
a very simple 64-bit dll  to allow me to experiment with this but to no
avail. All my DLL consists of is two functions, one that adds two doubles and returns a double and one that subtracts a double from another double and returns a double. When I try to add a=4, b=2 I get a nonsense answer that changes every time. Also ulink doesn't work at all nor does dllinfo although
I can examine the dll using dumpbin.


TestDLL1.zip <http://mailinglists.scilab.org/file/n4035379/TestDLL1.zip> TestDLL1.sce <http://mailinglists.scilab.org/file/n4035379/TestDLL1.sce>



--
View this message in context:
http://mailinglists.scilab.org/Scilab-users-Interfacing-to-third-party-DLLs-tp4035330p4035379.html
Sent from the Scilab users - Mailing Lists Archives mailing list
archive at Nabble.com.
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
extern "C"
{
#include "DLLtest1.h"
}

void Add(double* a, double* b, double* c)
{
	*c = *a + *b;
}

void Sub(double* a, double* b, double* c)
{
	*c = *a - *b;
}
#ifndef _DLL_TUTORIAL_H_
#define _DLL_TUTORIAL_H_

void Add(double* a, double* b, double* c);
void Sub(double* a, double* b, double* c);

#endif
//build
//use your path
cd d:\testDLL1;

//ilib_for_link export all symbols
ilib_for_link("TestDLL1", "DLLtest1.cpp", [], "-I.");

//link with scilab
Test_Functions= ["Add", "Sub"];
Test_Path = "libTestDLL1.dll";
Test_Lib = link(Test_Path, Test_Functions, 'c');

link("show")

a=4;
b=2;
c=0;
d=size(c);

c = call("Add", a, 1, "d", b, 2, "d", "out", d, 3, "d");
assert_checkequal(c, a + b);

c = call("Sub", a, 1, "d", b, 2, "d", "out", d, 3, "d");
assert_checkequal(c, a - b);

ulink(Test_Lib);
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to