LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with DLLs in Fortran

Solved!
Go to solution

For my  research I write LabVIEW (2020) mixed language programs with DLL’s in Fortran. The latter are created using the Intel Visual Fortran Compiler 2020 integrated into the Microsoft Visual Studio Community 2019 development environment (Windows10). In my long-term experience this is a very fruitful combination in which the heavy number crunching is delegated to the Fortran DLL’s and the LabVIEW GUI provides the vast and extensive flexibility in the I/O especially in the graphics.

 

I encounter a problem when converting my programs to executable applications under the NI runtime engine. The executables run fine on the host computer. They also run fine on a second computer with the NI runtime engine installed (and no LabVIEW Development System present). However, the Fortran DLL’s are not recognized (error message: Missing external function <name>.dll) only when the Fortran code contains calls to intrinsic trigonometric (SIN, COS) or exponential (EXP) functions. Other functions (REAL, INT, ABS, SQRT, MOD) do not lead to problems.

0 Kudos
Message 1 of 11
(168 Views)

This suggests to me the wrong dll (maybe incorrect version?).  Have you tried explicitly including the dll in your builds?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(149 Views)

@wrhagen wrote:

For my  research I write LabVIEW (2020) mixed language programs with DLL’s in Fortran. The latter are created using the Intel Visual Fortran Compiler 2020 ...


Of course, Intel Fortran Compiler RunTime is already installed on the target PC, isn't?

0 Kudos
Message 3 of 11
(131 Views)

Yes, I did.

0 Kudos
Message 4 of 11
(82 Views)

Yes, installed.

0 Kudos
Message 5 of 11
(80 Views)

@wrhagen wrote:

Yes, I did.


Something isn't installed. If you claim that you installed the correct Intel Fortran Runtime library (bitness is also correct?) something went wrong there!

 

Another option:you created Debug Build DLLs. Not sure about Intel Fortran but with Visual C they link to different debug runtime libraries that you can only get installed on a system by installing the full Visual Studio package. Redustributing those debug runtime libraries is even explicitly forbidden by Microsoft. You need to install Visual Studio and have a valid license to run it. Maybe Intel Fortran works similar?

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 11
(72 Views)

No, I did not create DEBUG DLLs; I created Release DLLs. 

PLease note that everything works fine with DLLs containing hundreds of Fortran lines until I include one single call to, for example, intrinsic function EXP.

0 Kudos
Message 7 of 11
(61 Views)

Does your fortran dll make calls on another dll?  If LabVIEW makes calls to A.dll, which calls B.dll, and you make an Executable, LabVIEW will take a copy of A.dll but not know to copy B.dll.  Solution is to ensure any extra dlls are explocitly included in the exe build.

0 Kudos
Message 8 of 11
(58 Views)

No, the Fortran DLLs do not make calls to other DLLs.

0 Kudos
Message 9 of 11
(54 Views)
Solution
Accepted by wrhagen

I’m not sure what intrinsic means in Fortran. In C it means a function call that is almost directly translated to an assembly code or a short sequence of it. However the symptoms you describe with LoadLibrary() failing clearly hint at something that goes wrong while Windows tries to load the DLL. Usually that are missing dependencies. But it can be a number of other things such as errors in the PE header, code segment setup and more. It certainly doesn’t look LabVIEW related. LabVIEW simply shows you the error it receives from Windows when trying to load the DLL.

That’s a problem for Intel Fortran support to look into.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 11
(43 Views)