I wrote a Fortran code and make it TestDLL.dll and TestDLL.lib file. I want use that in OpenModelica. But the Modelica say that
could not find library TestDLL in either of:~~~
I put .dll and .lib file in E:\MODELICAEXAM
(my modelica work space) or E:\MODELICAEXAM\MyPackage\Resouces
, but it doesn't work.
I read the ModelicaSpec34 document(12.9.4) which describe about "annotation", but I really confuse about what is "modelica://".
So I have two question about that:
- can I use fortran dll in the modelica?
- If first question is ok, where should I put my lib and dll file to make modelica find these files? or I misunderstood the question?
The code as below
function SUB(a,b)
!DEC$ ATTRIBUTES DLLEXPORT::SUB
implicit none
real :: a,b
real :: SUB
SUB = a+b
return
end
modelica part
model test
function sub
input Real a;
input Real b;
output Real Result;
external "C" Result = sub(a, b);
annotation(
Library = "TestDLL",
LibraryDirectory =
"modelica://MyPackage/Resouces");
end sub;
Real result;
parameter Real a = 1;
parameter Real b = 2;
equation
result = sub(a, b);
end test;!